Upload via GUI (293 Dateien)
This commit is contained in:
@@ -34,6 +34,7 @@ class MainForm : Form
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Width = 1280;
|
||||
Height = 800;
|
||||
MinimumSize = new System.Drawing.Size(480, 360);
|
||||
ShowInTaskbar = true;
|
||||
BackColor = System.Drawing.Color.Black;
|
||||
// No title bar / border. Close with Alt+F4, minimize via the taskbar button.
|
||||
@@ -41,7 +42,7 @@ class MainForm : Form
|
||||
|
||||
if (startMinimized)
|
||||
{
|
||||
// Autostart: sit minimized on the taskbar; maximize on first open.
|
||||
// Autostart: sit minimized on the taskbar; restore to a normal window on first open.
|
||||
WindowState = FormWindowState.Minimized;
|
||||
_pendingMaximize = true;
|
||||
Resize += (_, _) =>
|
||||
@@ -49,14 +50,12 @@ class MainForm : Form
|
||||
if (_pendingMaximize && WindowState != FormWindowState.Minimized)
|
||||
{
|
||||
_pendingMaximize = false;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
// else: leave WindowState at its default (Normal) -> starts as a normal
|
||||
// 1280x800 window, not maximized/fullscreen.
|
||||
|
||||
try
|
||||
{
|
||||
@@ -133,6 +132,10 @@ class MainForm : Form
|
||||
case "window-drag":
|
||||
StartWindowDrag();
|
||||
break;
|
||||
case "window-resize":
|
||||
if (root.TryGetProperty("edge", out var edgeProp))
|
||||
StartWindowResize(edgeProp.GetString());
|
||||
break;
|
||||
case "window-min":
|
||||
WindowState = FormWindowState.Minimized;
|
||||
break;
|
||||
@@ -224,6 +227,28 @@ class MainForm : Form
|
||||
SendMessage(Handle, WM_NCLBUTTONDOWN, (IntPtr)HTCAPTION, IntPtr.Zero);
|
||||
}
|
||||
|
||||
// --- Free window resize for the borderless window. The WebView2 control
|
||||
// fills the entire client area, so the OS never gets a chance to hit-test
|
||||
// the window's own edges for a resize cursor/drag -- every mouse message
|
||||
// lands in the browser first. The page (bundle.js) instead watches the
|
||||
// mouse position itself, and on mousedown within a few px of an edge/
|
||||
// corner sends "window-resize" with which edge; we hand off to the same
|
||||
// native resize loop Windows uses for a normal sizable window. ---
|
||||
private static readonly Dictionary<string, int> ResizeEdges = new()
|
||||
{
|
||||
["n"] = 12, ["s"] = 15, ["e"] = 11, ["w"] = 10,
|
||||
["ne"] = 14, ["nw"] = 13, ["se"] = 17, ["sw"] = 16,
|
||||
};
|
||||
|
||||
private void StartWindowResize(string? edge)
|
||||
{
|
||||
// Only a normal (non-maximized, non-minimized) window can be resized this way.
|
||||
if (WindowState != FormWindowState.Normal) return;
|
||||
if (edge == null || !ResizeEdges.TryGetValue(edge, out var htCode)) return;
|
||||
ReleaseCapture();
|
||||
SendMessage(Handle, WM_NCLBUTTONDOWN, (IntPtr)htCode, IntPtr.Zero);
|
||||
}
|
||||
|
||||
private static void OpenExternal(string uri)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user