Forge
csharpdeeb25a2
1using Avalonia;
2using Avalonia.Controls;
3using Avalonia.Layout;
4using Avalonia.Media;
5
6namespace CascadeIDE.Views;
7
8/// <summary>Диалог переименования темы Intercom.</summary>
9internal static class TopicRenameDialog
10{
11 public static async Task<string?> ShowAsync(Window? owner, string currentTitle)
12 {
13 if (owner is null)
14 return null;
15
16 var dialog = new Window
17 {
18 Title = "Переименовать тему",
19 Width = 440,
20 Height = 168,
21 CanResize = false,
22 WindowStartupLocation = WindowStartupLocation.CenterOwner,
23 };
24
25 var box = new TextBox
26 {
27 Text = currentTitle ?? "",
28 PlaceholderText = "Название темы",
29 Margin = new Thickness(0, 0, 0, 8),
30 };
31 string? result = null;
32
33 var ok = new Button { Content = "OK", MinWidth = 90, IsDefault = true };
34 var cancel = new Button { Content = "Отмена", MinWidth = 90, IsCancel = true };
35 ok.Click += (_, _) =>
36 {
37 var text = box.Text?.Trim() ?? "";
38 if (text.Length > 0)
39 result = text;
40 dialog.Close();
41 };
42 cancel.Click += (_, _) => dialog.Close();
43
44 dialog.Content = new StackPanel
45 {
46 Margin = new Thickness(16),
47 Spacing = 12,
48 Children =
49 {
50 new TextBlock
51 {
52 Text = "Новое название темы:",
53 TextWrapping = TextWrapping.Wrap,
54 },
55 box,
56 new StackPanel
57 {
58 Orientation = Orientation.Horizontal,
59 HorizontalAlignment = HorizontalAlignment.Right,
60 Spacing = 10,
61 Children = { ok, cancel },
62 },
63 },
64 };
65
66 await dialog.ShowDialog(owner);
67 return result;
68 }
69}
70
View only · write via MCP/CIDE