launcher: QR code + share buttons on host ready panel

The single Copy button left it on the user to format a message and
get the code into Discord/email. Added a layout that makes sharing
obvious:

- QR encodes the join code text so a friend with a phone can scan
  the host's screen and forward the code without typing it
- "Copy as message" formats a one-line "Join {server} on DorkNet!
  Download at github.com/... and paste this code:" pitch
- "Email to friend" opens the default mail client with subject +
  body prefilled, code in the body
- QR built via QRCoder -> WriteableBitmap directly (no
  System.Drawing dependency); palette matches the launcher
This commit is contained in:
Alexa
2026-05-27 11:11:31 +03:00
parent 3039bebc6c
commit 3aa0b55512
4 changed files with 150 additions and 15 deletions
+33
View File
@@ -331,6 +331,7 @@ public partial class MainWindow : Window
Name = _state.ServerName,
});
JoinCodeText.Text = code;
JoinCodeQrImage.Source = QrCodeRenderer.Render(code);
JoinCodePanel.Visibility = Visibility.Visible;
HostStatusText.Text = _state.HostingMode == HostingMode.LocalNetwork
? $"Hosting on your local network at {_hostApex}. Share the join code with friends on the same WiFi."
@@ -408,6 +409,38 @@ public partial class MainWindow : Window
catch (Exception ex) { ShowError("Copy failed: " + ex.Message); }
}
private void OnCopyJoinCodeMessage(object sender, RoutedEventArgs e)
{
var name = string.IsNullOrWhiteSpace(_state.ServerName)
? "my DorkNet server"
: _state.ServerName;
var msg =
$"Join {name} on DorkNet! Grab the launcher at " +
"https://github.com/DorkSquadRR/DorkNet and paste this code:\n\n" +
JoinCodeText.Text;
try { Clipboard.SetText(msg); }
catch (Exception ex) { ShowError("Copy failed: " + ex.Message); }
}
private void OnEmailJoinCode(object sender, RoutedEventArgs e)
{
var name = string.IsNullOrWhiteSpace(_state.ServerName)
? "my DorkNet server"
: _state.ServerName;
// mailto: body is URL-encoded; Uri.EscapeDataString handles
// the newlines + code text without trashing slashes or =.
var subject = Uri.EscapeDataString($"Join {name} on DorkNet");
var body = Uri.EscapeDataString(
$"Hey! Want to play on {name}?\n\n" +
"1. Download the DorkNet launcher: https://github.com/DorkSquadRR/DorkNet\n" +
"2. Open it and pick \"Join a friend\"\n" +
"3. Paste this code:\n\n" +
JoinCodeText.Text);
try { Process.Start(new ProcessStartInfo($"mailto:?subject={subject}&body={body}")
{ UseShellExecute = true }); }
catch (Exception ex) { ShowError("Email failed: " + ex.Message); }
}
// ── Join flow ───────────────────────────────────────────────────────
private void OnJoinCodeInputChanged(object sender, TextChangedEventArgs e)
=> RefreshJoinReadiness();