Fix button spacing, opacity simplification, gitignore cleanup
This commit is contained in:
1 parent
36fd5a6b6e
commit
cdd3414771
10 files changed
+135
-21
No files matched your search
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Windows;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
|
||||
namespace Gott;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly AppSettings _settings;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
_settings = LoadSettings();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var screenW = SystemParameters.PrimaryScreenWidth;
|
||||
var screenH = SystemParameters.PrimaryScreenHeight;
|
||||
Width = 930;
|
||||
Height = screenH * 0.95;
|
||||
Left = (screenW - Width) / 2;
|
||||
Top = (screenH - Height) / 2;
|
||||
|
||||
Loaded += async (_, _) =>
|
||||
{
|
||||
await webView.EnsureCoreWebView2Async();
|
||||
|
||||
// Dark background to avoid white flash
|
||||
webView.DefaultBackgroundColor = System.Drawing.Color.FromArgb(255, 17, 17, 17);
|
||||
|
||||
// Open external links in default browser
|
||||
webView.CoreWebView2.NewWindowRequested += (_, e) =>
|
||||
{
|
||||
e.Handled = true;
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri) { UseShellExecute = true });
|
||||
};
|
||||
|
||||
webView.CoreWebView2.NavigationCompleted += (_, _) =>
|
||||
{
|
||||
webView.Visibility = Visibility.Visible;
|
||||
loader.Visibility = Visibility.Collapsed;
|
||||
};
|
||||
|
||||
webView.CoreWebView2.Navigate(_settings.Url);
|
||||
};
|
||||
}
|
||||
|
||||
private static AppSettings LoadSettings()
|
||||
{
|
||||
foreach (var file in new[] { "appsettings.Production.json", "appsettings.json" })
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, file);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize<AppSettings>(json) ?? new();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
public string Url { get; set; } = "http://localhost:19000";
|
||||
}
|
||||
Reference in new issue
Block a user