Coding for Package Manager.

This commit is contained in:
Bruce
2026-01-20 22:34:22 +08:00
parent 7483ed6930
commit 75cb72964d
71 changed files with 5518 additions and 13351 deletions
+21 -13
View File
@@ -32,6 +32,7 @@ namespace WAShell
if (ReferenceEquals (_host, value)) return;
DetachHostEvents (_host);
_host = value;
this.Owner = _host as Form;
AttachHostEvents (_host);
if (this.Visible)
{
@@ -44,19 +45,27 @@ namespace WAShell
if (host == null) return;
host.Resize += Host_Changed;
host.LocationChanged += Host_Changed;
host.Disposed += Host_Disposed;
}
private void DetachHostEvents (Control host)
{
if (host == null) return;
host.Resize -= Host_Changed;
host.LocationChanged -= Host_Changed;
host.Disposed -= Host_Disposed;
}
private void Host_Changed (object sender, EventArgs e)
{
if (!this.IsHandleCreated) return;
if (this.IsDisposed || !this.IsHandleCreated) return;
if (this.Owner == null || this.Owner.IsDisposed) return;
ResizeSplashScreen ();
}
private void Host_Disposed (object sender, EventArgs e)
{
DetachHostEvents (_host);
_host = null;
if (!this.IsDisposed) this.Hide (); // 或 Hide()
}
public SplashForm ()
{
InitializeComponent ();
@@ -80,7 +89,7 @@ namespace WAShell
splashImage = value;
if (picbox != null && picbox.IsHandleCreated)
{
splashImage = picbox.Image;
picbox.Image = splashImage;
}
}
}
@@ -98,15 +107,14 @@ namespace WAShell
{
ResizeSplashScreen ();
}
private void ResizeSplashScreen ()
public void ResizeSplashScreen ()
{
Control owner = this.Owner;
if (owner == null) owner = this.Parent;
if (owner == null) return;
owner.Update ();
var pt = owner.PointToScreen (owner.ClientRectangle.Location);
Location = pt;
Size = owner.ClientSize;
if (this.IsDisposed || !this.IsHandleCreated) return;
Control owner = this.Owner ?? this.Parent;
if (owner == null || owner.IsDisposed || !owner.IsHandleCreated) return;
var pt = owner.PointToScreen (Point.Empty);
this.Location = pt;
this.Size = owner.ClientSize;
ResizeSplashImage ();
}
private void ResizeSplashImage ()
@@ -213,13 +221,13 @@ namespace WAShell
{
DetachHostEvents (_host);
_host = null;
base.OnFormClosed (e);
// base.OnFormClosed (e);
}
catch (Exception) { }
}
private void SplashForm_Shown (object sender, EventArgs e)
{
base.OnShown (e);
//base.OnShown (e);
this.Opacity = 1.0;
this.Visible = true;
this.Enabled = true;
+4
View File
@@ -68,6 +68,10 @@
<Project>{ffd3fd52-37a8-4f43-883c-de8d996cb0e0}</Project>
<Name>DataUtils</Name>
</ProjectReference>
<ProjectReference Include="..\IEHelper\IEHelper.vcxproj">
<Project>{e4ca78a9-9408-4f5f-add6-730fd501ff8e}</Project>
<Name>IEHelper</Name>
</ProjectReference>
<ProjectReference Include="..\PrivateInit\PrivateInit.csproj">
<Project>{8e708d9a-6325-4aa9-b5a5-d1b5eca8eef7}</Project>
<Name>PrivateInit</Name>
+3
View File
@@ -39,6 +39,7 @@
this.webui.Name = "webui";
this.webui.Size = new System.Drawing.Size(661, 416);
this.webui.TabIndex = 0;
this.webui.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webui_DocumentCompleted);
//
// WebAppForm
//
@@ -49,6 +50,8 @@
this.Controls.Add(this.webui);
this.Name = "WebAppForm";
this.Text = "Main Web App Form";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WebAppForm_FormClosing);
this.Load += new System.EventHandler(this.WebAppForm_Load);
this.ResumeLayout(false);
}
+72 -38
View File
@@ -12,56 +12,90 @@ namespace WAShell
{
[ComVisible (true)]
[ClassInterface (ClassInterfaceType.AutoDual)]
public partial class WebAppForm: Form, IScriptBridge, IWebBrowserPageScale
public partial class WebAppForm: Form, IScriptBridge, IWebBrowserPageScale, ITaskbarProgress
{
SplashForm splash;
ITaskbarList3 taskbar = null;
SplashForm splash = new SplashForm ();
TaskbarProgress taskbar = null;
public WebBrowser WebUI => webui;
public SplashForm SplashScreen => splash;
public object PublicObjectForScripting { get { return webui?.ObjectForScripting; } set { webui.ObjectForScripting = null; webui.ObjectForScripting = value; } }
protected Bridge._I_BridgeBase NowObject { get { return webui?.ObjectForScripting as Bridge._I_BridgeBase; } }
public WebAppForm ()
{
splash.Host = this;
InitializeComponent ();
webui.ObjectForScripting = new Bridge._I_BridgeBase (this, this, this, this);
taskbar = new TaskbarProgress (Handle);
}
public int PageScale
public virtual int PageScale
{
get { return IEHelper.WebBrowserHelper.GetPageScale (webui); }
set { IEHelper.WebBrowserHelper.SetPageScale (webui, value); }
}
public double ProgressValue
{
get
{
var web2 = WebBrowserHelper.GetWebBrowser2 (webui);
if (web2 == null) return 0;
object inArg = null;
object outArg = null;
try
{
web2.ExecWB (
OLECMDID.OLECMDID_OPTICAL_ZOOM,
OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT,
ref inArg,
ref outArg
);
if (outArg is int) return (int)outArg;
}
catch { }
return 0;
}
set
{
var web2 = WebBrowserHelper.GetWebBrowser2 (webui);
if (web2 == null) return;
object inArg = value;
object outArg = null;
try
{
web2.ExecWB (
OLECMDID.OLECMDID_OPTICAL_ZOOM,
OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
ref inArg,
ref outArg
);
}
catch { }
if (taskbar == null) return;
double total = 1000000;
taskbar.SetValue ((ulong)(value * total), (ulong)total);
}
}
public object CallEvent (string funcName, object e)
public TBPFLAG ProgressStatus { set { taskbar.SetState (value); } }
public virtual object CallEvent (string funcName, object e)
{
return null;
}
private void WebAppForm_Load (object sender, EventArgs e)
{
// splash.SplashBackgroundColor = Color.Green;
splash.ResizeSplashScreen ();
splash.Show ();
splash.Update ();
// splash.FadeOut ();
}
private bool issetdpi = false;
protected virtual void webui_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (!issetdpi)
{
issetdpi = true;
ExecScript ("Bridge.Frame.scale = Bridge.Frame.scale * Bridge.UI.dpi");
}
ExecScript ("Windows.UI.DPI.mode = 1");
if (e.Url.ToString () == webui.Url.ToString ())
{
splash.FadeOut ();
}
}
protected object CallScriptFunction (string funcName, params object [] args) { return webui.Document.InvokeScript (funcName, args); }
protected object CallScriptFunction (string funcName) { return webui.Document.InvokeScript (funcName); }
public object InvokeCallScript (string funcName, params object [] args)
{
if (this.InvokeRequired)
{
return this.Invoke (
new Func<string, object [], object> (CallScriptFunction),
funcName, args
);
}
else return CallScriptFunction (funcName, args);
}
public object InvokeCallScript (string funcName)
{
if (this.InvokeRequired)
{
return this.Invoke (
new Func<string, object> (CallScriptFunction),
funcName
);
}
else return CallScriptFunction (funcName);
}
public object ExecScript (params object [] cmdline) { return InvokeCallScript ("eval", cmdline); }
private void WebAppForm_FormClosing (object sender, FormClosingEventArgs e)
{
webui.ObjectForScripting = null;
}
}
}