From e2d07826ede5c1df0f884ef8a59e0a89c95b7d08 Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期三, 12 八月 2026 20:43:29 +0800
Subject: [PATCH] 移除发布文件
---
src/Moli.Desktop/Management/ManagementWindow.xaml.cs | 416 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 388 insertions(+), 28 deletions(-)
diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
index f22bbac..b2aef4b 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
@@ -1,11 +1,24 @@
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Text.Encodings.Web;
+using System.Text.Json;
+using System.Text.Json.Serialization;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Threading;
using Moli.Desktop.Api;
+using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Host;
using Moli.Desktop.Layout;
using Moli.Desktop.Plugins;
using Moli.Desktop.Runtime;
+using Microsoft.Win32;
using MessageBox = System.Windows.MessageBox;
+using WpfButton = System.Windows.Controls.Button;
+using WpfTextBox = System.Windows.Controls.TextBox;
namespace Moli.Desktop.Management;
@@ -14,18 +27,25 @@
private readonly IDesktopRuntime _runtime;
private readonly IDiagnosticsService _diagnostics;
private readonly ILocalApiStatus _apiStatus;
+ private readonly DesktopPaths _paths;
private readonly DispatcherTimer _timer;
private AppRuntimeState? _state;
+ private string? _selectedWidgetForDisplayLayer;
+ private bool _isRefreshing;
public ManagementWindow(
IDesktopRuntime runtime,
IDiagnosticsService diagnostics,
- ILocalApiStatus apiStatus)
+ ILocalApiStatus apiStatus,
+ DesktopPaths paths)
{
_runtime = runtime;
_diagnostics = diagnostics;
_apiStatus = apiStatus;
+ _paths = paths;
InitializeComponent();
+ DisplayLayerSelector.ItemsSource = Enum.GetValues<DisplayLayer>();
+ WidgetSelector.SelectionChanged += WidgetSelector_SelectionChanged;
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
_timer.Tick += async (_, _) => await RefreshAsync();
Loaded += async (_, _) =>
@@ -38,32 +58,42 @@
private async Task RefreshAsync()
{
- _state = await _runtime.GetStateAsync();
- var api = _apiStatus.GetStatus();
- var diagnostics = _diagnostics.Snapshot().OrderByDescending(entry => entry.Timestamp).ToArray();
- var webViewStatus = diagnostics.FirstOrDefault(entry => entry.Code == DiagnosticCodes.WebViewHostInitialized) is null
- ? "鏈娴嬪埌鍒濆鍖栬褰�"
- : "宸插垵濮嬪寲";
+ _isRefreshing = true;
+ try
+ {
+ _state = await _runtime.GetStateAsync();
+ var api = _apiStatus.GetStatus();
+ var diagnostics = _diagnostics.Snapshot().OrderByDescending(entry => entry.Timestamp).ToArray();
+ var webViewStatus = diagnostics.FirstOrDefault(entry => entry.Code == DiagnosticCodes.WebViewHostInitialized) is null
+ ? "鏈娴嬪埌鍒濆鍖栬褰�"
+ : "宸插垵濮嬪寲";
- StatusSummaryText.Text = $"鎻掍欢 {_state.Plugins.Count} 涓紝缁勪欢 {_state.Widgets.Count} 涓紝璇婃柇 {diagnostics.Length} 鏉�";
- RuntimeText.Text = $"杩愯鏃讹細缂栬緫={_state.IsEditMode}锛屽畨鍏ㄨ緭鍏�={_state.IsSafeInputMode}锛屽叏灞�閿佸畾={_state.IsGlobalLocked}";
- ApiText.Text = api.IsListening ? $"API锛�127.0.0.1:{api.Port}" : $"API锛氭湭鐩戝惉 {api.ErrorCode ?? ""}";
- WallpaperText.Text = $"澹佺焊锛氬惎鐢�={_state.Wallpaper.IsEnabled}锛屾彃浠�={_state.Wallpaper.PluginId?.Value ?? "鏃�"}";
- WebViewText.Text = $"WebView2锛歿webViewStatus}";
- WallpaperDetailText.Text = $"鍚敤锛歿_state.Wallpaper.IsEnabled}\n鏆傚仠锛歿_state.Wallpaper.IsPaused}\n闈欓煶锛歿_state.Wallpaper.IsMuted}\n閫忔槑搴︼細{_state.Wallpaper.Opacity}\n鐐瑰嚮绌块�忥細{_state.Wallpaper.ClickThrough}";
- EditModeButton.Content = _state.IsEditMode ? "閫�鍑虹紪杈�" : "杩涘叆缂栬緫";
- SafeInputButton.Content = _state.IsSafeInputMode ? "閫�鍑哄畨鍏�" : "瀹夊叏杈撳叆";
- GlobalLockButton.Content = _state.IsGlobalLocked ? "瑙i攣鍏ㄩ儴" : "閿佸畾鍏ㄩ儴";
+ StatusSummaryText.Text = $"鎻掍欢 {_state.Plugins.Count} 涓紝缁勪欢 {_state.Widgets.Count} 涓紝璇婃柇 {diagnostics.Length} 鏉�";
+ RuntimeText.Text = $"杩愯鏃讹細缂栬緫={_state.IsEditMode}锛屽畨鍏ㄨ緭鍏�={_state.IsSafeInputMode}锛屽叏灞�閿佸畾={_state.IsGlobalLocked}";
+ ApiText.Text = api.IsListening ? $"API锛�127.0.0.1:{api.Port}" : $"API锛氭湭鐩戝惉 {api.ErrorCode ?? ""}";
+ WallpaperText.Text = $"澹佺焊锛氬惎鐢�={_state.Wallpaper.IsEnabled}锛屾彃浠�={_state.Wallpaper.PluginId?.Value ?? "鏃�"}";
+ WebViewText.Text = $"WebView2锛歿webViewStatus}";
+ WallpaperDetailText.Text = $"鍚敤锛歿_state.Wallpaper.IsEnabled}\n鏆傚仠锛歿_state.Wallpaper.IsPaused}\n闈欓煶锛歿_state.Wallpaper.IsMuted}\n閫忔槑搴︼細{_state.Wallpaper.Opacity}\n鐐瑰嚮绌块�忥細{_state.Wallpaper.ClickThrough}";
+ EditModeButton.Content = _state.IsEditMode ? "閫�鍑虹紪杈�" : "杩涘叆缂栬緫";
+ SafeInputButton.Content = _state.IsSafeInputMode ? "閫�鍑哄畨鍏�" : "瀹夊叏杈撳叆";
+ GlobalLockButton.Content = _state.IsGlobalLocked ? "瑙i攣鍏ㄩ儴" : "閿佸畾鍏ㄩ儴";
- var widgets = _state.Widgets.Select(WidgetRow.From).ToArray();
- var selected = (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId;
- WidgetSelector.ItemsSource = widgets;
- WidgetSelector.SelectedItem = widgets.FirstOrDefault(widget => widget.InstanceId == selected) ?? widgets.FirstOrDefault();
- WidgetsGrid.ItemsSource = widgets;
- PluginsGrid.ItemsSource = _state.Plugins.Select(PluginRow.From).ToArray();
- DiagnosticsGrid.ItemsSource = diagnostics.Select(DiagnosticRow.From).ToArray();
- RecentDiagnosticsGrid.ItemsSource = diagnostics.Take(8).Select(DiagnosticRow.From).ToArray();
- ManifestErrorsText.Text = BuildManifestErrorText(_state);
+ var widgets = _state.Widgets.Select(WidgetRow.From).ToArray();
+ var selected = (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId;
+ WidgetSelector.ItemsSource = widgets;
+ WidgetSelector.SelectedItem = widgets.FirstOrDefault(widget => widget.InstanceId == selected) ?? widgets.FirstOrDefault();
+ WidgetsGrid.ItemsSource = widgets;
+ SyncDisplayLayerSelector(force: _selectedWidgetForDisplayLayer != (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId);
+ PluginsGrid.ItemsSource = _state.Plugins.Select(PluginRow.From).ToArray();
+ DiagnosticsGrid.ItemsSource = diagnostics.Select(DiagnosticRow.From).ToArray();
+ RecentDiagnosticsGrid.ItemsSource = diagnostics.Take(8).Select(DiagnosticRow.From).ToArray();
+ ManifestErrorsText.Text = BuildManifestErrorText(_state);
+ LoadTodayLog();
+ }
+ finally
+ {
+ _isRefreshing = false;
+ }
}
private async void RefreshButton_Click(object sender, RoutedEventArgs e) => await RefreshAsync();
@@ -73,6 +103,30 @@
private async void ToggleSafeInput_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.SetSafeInputModeAsync(!(_state?.IsSafeInputMode ?? false)));
private async void ToggleGlobalLock_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.SetGlobalLockedAsync(!(_state?.IsGlobalLocked ?? false)));
private async void ReloadPlugins_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.ReloadPluginsAsync());
+ private async void ApplyDisplayLayer_Click(object sender, RoutedEventArgs e)
+ {
+ if (SelectedWidget() is not { } widget || DisplayLayerSelector.SelectedItem is not DisplayLayer layer)
+ {
+ return;
+ }
+
+ if (layer == DisplayLayer.GlobalTop)
+ {
+ var choice = MessageBox.Show(
+ this,
+ "鍏ㄥ眬缃《浼氳璇ョ粍浠惰鐩栧叾浠栧簲鐢ㄧ獥鍙c�傜‘璁ょ户缁紵",
+ "鍏ㄥ眬缃《",
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Warning);
+ if (choice != MessageBoxResult.Yes)
+ {
+ return;
+ }
+ }
+
+ await _runtime.CancelPluginRequestsAsync(new PluginId(widget.PluginId));
+ await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { DisplayLayer = layer });
+ }
private async void ToggleWidgetVisible_Click(object sender, RoutedEventArgs e)
{
@@ -95,10 +149,30 @@
}
private async void ResetLayout_Click(object sender, RoutedEventArgs e)
+ => await ResetRuntimeLayoutAsync(confirm: false);
+
+ private async void RestoreDefaults_Click(object sender, RoutedEventArgs e)
+ => await ResetRuntimeLayoutAsync(confirm: true);
+
+ private async Task ResetRuntimeLayoutAsync(bool confirm)
{
if (_state is null)
{
return;
+ }
+
+ if (confirm)
+ {
+ var choice = MessageBox.Show(
+ this,
+ "纭鎭㈠榛樿甯冨眬鍜屼氦浜掗厤缃紵姝ゆ搷浣滀細鏄剧ず骞惰В閿佺粍浠讹紝鎭㈠閫忔槑搴︺�佺偣鍑荤┛閫忓拰榛樿鏄剧ず灞傜骇銆�",
+ "鎭㈠榛樿",
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Warning);
+ if (choice != MessageBoxResult.Yes)
+ {
+ return;
+ }
}
foreach (var widget in _state.Widgets)
@@ -110,14 +184,215 @@
IsVisible = true,
IsLocked = false,
Opacity = 1,
- ClickThrough = true
+ ClickThrough = true,
+ DisplayLayer = DisplayLayer.Desktop
});
}
await RefreshAsync();
}
+ private async void EditWidgetLayout_Click(object sender, RoutedEventArgs e)
+ {
+ if (SelectedWidget() is not { } widget)
+ {
+ return;
+ }
+
+ var dialog = new WidgetLayoutDialog(widget) { Owner = this };
+ if (dialog.ShowDialog() == true)
+ {
+ await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { Bounds = dialog.Bounds });
+ }
+ }
+
+ private void OpenLayoutJson_Click(object sender, RoutedEventArgs e)
+ => OpenJson(Path.Combine(_paths.ConfigDirectory, "layout.json"));
+
+ private void OpenPluginsJson_Click(object sender, RoutedEventArgs e)
+ => OpenJson(Path.Combine(_paths.ConfigDirectory, "plugins.json"));
+
+ private void OpenLogDirectory_Click(object sender, RoutedEventArgs e)
+ {
+ Directory.CreateDirectory(_paths.LogDirectory);
+ Process.Start(new ProcessStartInfo("explorer.exe", $"\"{_paths.LogDirectory}\"") { UseShellExecute = true });
+ }
+
+ private void OpenPluginJson_Click(object sender, RoutedEventArgs e)
+ {
+ if ((PluginsGrid.SelectedItem as PluginRow) is not { } plugin)
+ {
+ return;
+ }
+
+ OpenJson(Path.Combine(_paths.PluginDirectory, plugin.Id, "plugin.json"));
+ }
+
+ private async void ChooseWallpaperFile_Click(object sender, RoutedEventArgs e)
+ {
+ var dialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Title = "閫夋嫨澹佺焊鏂囦欢",
+ Filter = "澹佺焊鏂囦欢|*.html;*.htm;*.png;*.jpg;*.jpeg;*.gif;*.svg|HTML|*.html;*.htm|鍥剧墖|*.png;*.jpg;*.jpeg;*.gif;*.svg|鎵�鏈夋枃浠秥*.*"
+ };
+ if (dialog.ShowDialog(this) != true)
+ {
+ return;
+ }
+
+ await InstallWallpaperFilePluginAsync(dialog.FileName);
+ await ExecuteAsync(() => _runtime.ReloadPluginsAsync());
+ await ExecuteAsync(() => _runtime.EnableWallpaperAsync());
+ }
+
private WidgetRow? SelectedWidget() => WidgetSelector.SelectedItem as WidgetRow;
+
+ private void WidgetSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!_isRefreshing)
+ {
+ SyncDisplayLayerSelector(force: true);
+ }
+ }
+
+ private void SyncDisplayLayerSelector(bool force)
+ {
+ if (SelectedWidget() is not { } widget)
+ {
+ DisplayLayerSelector.SelectedItem = DisplayLayer.Desktop;
+ _selectedWidgetForDisplayLayer = null;
+ return;
+ }
+
+ if (!force)
+ {
+ return;
+ }
+
+ DisplayLayerSelector.SelectedItem = widget.DisplayLayer;
+ _selectedWidgetForDisplayLayer = widget.InstanceId;
+ }
+
+ private void LoadTodayLog()
+ {
+ var logPath = Path.Combine(_paths.LogDirectory, $"moli-desktop-{DateTimeOffset.Now:yyyyMMdd}.log");
+ LogPathText.Text = logPath;
+ if (!File.Exists(logPath))
+ {
+ LogTextBox.Text = "褰撳ぉ鏆傛棤鏃ュ織銆�";
+ return;
+ }
+
+ try
+ {
+ var text = File.ReadAllText(logPath, Encoding.UTF8);
+ if (LogTextBox.Text == text)
+ {
+ return;
+ }
+
+ var wasNearBottom = LogTextBox.VerticalOffset >= LogTextBox.ExtentHeight - LogTextBox.ViewportHeight - 24;
+ LogTextBox.Text = text;
+ if (wasNearBottom)
+ {
+ LogTextBox.ScrollToEnd();
+ }
+ }
+ catch (IOException)
+ {
+ }
+ catch (UnauthorizedAccessException)
+ {
+ }
+ }
+
+ private async Task InstallWallpaperFilePluginAsync(string fileName)
+ {
+ Directory.CreateDirectory(_paths.PluginDirectory);
+ var pluginDirectory = Path.Combine(_paths.PluginDirectory, "user.wallpaper-file");
+ Directory.CreateDirectory(pluginDirectory);
+
+ var extension = Path.GetExtension(fileName).ToLowerInvariant();
+ var uri = new Uri(fileName).AbsoluteUri;
+ var body = extension switch
+ {
+ ".html" or ".htm" => $"<iframe src=\"{Html(uri)}\"></iframe>",
+ ".svg" => $"<object data=\"{Html(uri)}\" type=\"image/svg+xml\"></object>",
+ _ => $"<img src=\"{Html(uri)}\" alt=\"wallpaper\" />"
+ };
+ var indexHtml = $$"""
+<!doctype html>
+<html lang="zh-CN">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <style>
+ html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #05070a; }
+ img, object, iframe { width: 100vw; height: 100vh; border: 0; object-fit: cover; display: block; }
+ </style>
+</head>
+<body>
+ {{body}}
+</body>
+</html>
+""";
+ await File.WriteAllTextAsync(Path.Combine(pluginDirectory, "index.html"), indexHtml, new UTF8Encoding(false));
+ var manifest = new
+ {
+ id = "user.wallpaper-file",
+ name = "鐢ㄦ埛閫夋嫨澹佺焊",
+ version = "1.0.0",
+ type = "wallpaper",
+ entry = "index.html",
+ description = $"Loaded from {Path.GetFileName(fileName)}.",
+ author = "Moli.Desktop",
+ permissions = Array.Empty<string>(),
+ defaultLayout = new { width = 1920, height = 1080, x = 0, y = 0, locked = true, clickThrough = true, opacity = 1, scale = 1, displayLayer = "desktop" },
+ config = new { sourceFile = fileName, sourceType = extension.TrimStart('.') }
+ };
+ await File.WriteAllTextAsync(
+ Path.Combine(pluginDirectory, "plugin.json"),
+ JsonSerializer.Serialize(manifest, new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }),
+ new UTF8Encoding(false));
+
+ await PreferWallpaperPluginAsync("user.wallpaper-file");
+ }
+
+ private async Task PreferWallpaperPluginAsync(string pluginId)
+ {
+ var path = Path.Combine(_paths.ConfigDirectory, "plugins.json");
+ if (!File.Exists(path))
+ {
+ return;
+ }
+
+ var options = new JsonSerializerOptions(JsonSerializerDefaults.Web)
+ {
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ using var stream = File.OpenRead(path);
+ var registry = await JsonSerializer.DeserializeAsync<PluginRegistryDocument>(stream, options);
+ if (registry is null)
+ {
+ return;
+ }
+
+ registry.Plugins.RemoveAll(item => item.Id.Value is "sample.wallpaper" or "user.wallpaper-file");
+ registry.Plugins.Insert(0, new PluginRegistryItem { Id = new PluginId(pluginId), State = PluginState.Enabled, UpdatedAt = DateTimeOffset.UtcNow });
+ registry.Plugins.Add(new PluginRegistryItem { Id = new PluginId("sample.wallpaper"), State = PluginState.Disabled, UpdatedAt = DateTimeOffset.UtcNow });
+ await File.WriteAllTextAsync(path, JsonSerializer.Serialize(registry, new JsonSerializerOptions(options) { WriteIndented = true }), new UTF8Encoding(false));
+ }
+
+ private void OpenJson(string path)
+ {
+ if (!File.Exists(path))
+ {
+ MessageBox.Show(this, $"鏂囦欢涓嶅瓨鍦細{path}", "鎵撳紑閰嶇疆", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ Process.Start(new ProcessStartInfo("notepad.exe", $"\"{path}\"") { UseShellExecute = true });
+ }
private async Task ExecuteAsync(Func<Task<OperationResult<AppRuntimeState>>> command)
{
@@ -150,7 +425,9 @@
return errors.Length == 0 ? "鏈彂鐜版彃浠� manifest 閿欒銆�" : string.Join(Environment.NewLine, errors);
}
- private sealed record WidgetRow(string InstanceId, string PluginId, string Bounds, string MonitorId, bool IsVisible, bool IsLocked, double Opacity, bool ClickThrough)
+ private static string Html(string value) => System.Net.WebUtility.HtmlEncode(value);
+
+ private sealed record WidgetRow(string InstanceId, string PluginId, string Bounds, string MonitorId, bool IsVisible, bool IsLocked, double Opacity, bool ClickThrough, DisplayLayer DisplayLayer)
{
public static WidgetRow From(WidgetRuntimeState state)
=> new(
@@ -161,7 +438,8 @@
state.IsVisible,
state.IsLocked,
state.Opacity,
- state.ClickThrough);
+ state.ClickThrough,
+ state.DisplayLayer);
}
private sealed record PluginRow(string Id, string Name, string Type, string State, string? ErrorCode, string Entry)
@@ -175,4 +453,86 @@
public static DiagnosticRow From(DiagnosticEntry entry)
=> new(entry.Timestamp, entry.Severity.ToString(), entry.Code, entry.Message);
}
+
+ private sealed class WidgetLayoutDialog : Window
+ {
+ private readonly WpfTextBox _x;
+ private readonly WpfTextBox _y;
+ private readonly WpfTextBox _width;
+ private readonly WpfTextBox _height;
+
+ public WidgetLayoutDialog(WidgetRow widget)
+ {
+ Title = "缂栬緫浣嶇疆/澶у皬";
+ Width = 320;
+ Height = 230;
+ WindowStartupLocation = WindowStartupLocation.CenterOwner;
+ ResizeMode = ResizeMode.NoResize;
+ var parts = widget.Bounds.Replace("x", " ").Replace(",", " ").Split(' ', StringSplitOptions.RemoveEmptyEntries);
+ _x = Box(parts.ElementAtOrDefault(0) ?? "0");
+ _y = Box(parts.ElementAtOrDefault(1) ?? "0");
+ _width = Box(parts.ElementAtOrDefault(2) ?? "320");
+ _height = Box(parts.ElementAtOrDefault(3) ?? "160");
+
+ var grid = new Grid { Margin = new Thickness(16) };
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(72) });
+ grid.ColumnDefinitions.Add(new ColumnDefinition());
+ for (var i = 0; i < 5; i++)
+ {
+ grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
+ }
+
+ AddRow(grid, 0, "X", _x);
+ AddRow(grid, 1, "Y", _y);
+ AddRow(grid, 2, "瀹藉害", _width);
+ AddRow(grid, 3, "楂樺害", _height);
+ var buttons = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, Margin = new Thickness(0, 12, 0, 0) };
+ var ok = new WpfButton { Content = "纭畾", Width = 72, Margin = new Thickness(0, 0, 8, 0) };
+ var cancel = new WpfButton { Content = "鍙栨秷", Width = 72 };
+ ok.Click += (_, _) =>
+ {
+ if (TryBuildBounds())
+ {
+ DialogResult = true;
+ }
+ };
+ cancel.Click += (_, _) => DialogResult = false;
+ buttons.Children.Add(ok);
+ buttons.Children.Add(cancel);
+ Grid.SetRow(buttons, 4);
+ Grid.SetColumnSpan(buttons, 2);
+ grid.Children.Add(buttons);
+ Content = grid;
+ }
+
+ public RectD Bounds { get; private set; }
+
+ private bool TryBuildBounds()
+ {
+ if (double.TryParse(_x.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out var x)
+ && double.TryParse(_y.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out var y)
+ && double.TryParse(_width.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out var width)
+ && double.TryParse(_height.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out var height))
+ {
+ Bounds = new RectD(x, y, width, height);
+ return true;
+ }
+
+ MessageBox.Show(this, "璇疯緭鍏ユ湁鏁堟暟瀛椼��", "缂栬緫浣嶇疆/澶у皬", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return false;
+ }
+
+ private static WpfTextBox Box(string text) => new() { Text = text, Margin = new Thickness(0, 0, 0, 8) };
+
+ private static void AddRow(Grid grid, int row, string label, WpfTextBox textBox)
+ {
+ var text = new TextBlock { Text = label, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 8, 8) };
+ Grid.SetRow(text, row);
+ Grid.SetColumn(text, 0);
+ Grid.SetRow(textBox, row);
+ Grid.SetColumn(textBox, 1);
+ grid.Children.Add(text);
+ grid.Children.Add(textBox);
+ }
+ }
}
--
Gitblit v1.9.1