Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

chore(windows): finish the Mac-design restyle of every screen

wquguru03a61bc32b68
diff --git a/windows/src/Cicada.Core/Settings.cs b/windows/src/Cicada.Core/Settings.cs
index a3fb631..62864d1 100644
--- a/windows/src/Cicada.Core/Settings.cs
+++ b/windows/src/Cicada.Core/Settings.cs
@@ -13,6 +13,8 @@ public sealed class AppSettings
[JsonPropertyName("model")] public string Model { get; set; } = LingClient.DefaultModel;
/// "notes" (the notes window, default) or "subtitles" (the subtitle bar).
[JsonPropertyName("view")] public string View { get; set; } = "notes";
+ /// Whether 知了还在任务栏右下角 was shown, after the first × on a window.
+ [JsonPropertyName("trayHintShown")] public bool TrayHintShown { get; set; }
/// 共享屏幕时让对方看到: let the notes window and subtitles show up in screen sharing.
[JsonPropertyName("showInCapture")] public bool ShowInCapture { get; set; }
[JsonPropertyName("onboarded")] public bool Onboarded { get; set; }
diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.cs
index 2ad6a2b..4b7a235 100644
--- a/windows/src/Cicada/App.cs
+++ b/windows/src/Cicada/App.cs
@@ -133,10 +133,11 @@ sealed class Controller
tray.Icon = idleIcon;
tray.Text = L("知了");
tray.Visible = true;
- // Left click: the flyout. Right click: the menu. Both are WPF, so they look like Windows 11.
+ // Left click: the panel, or while listening the notes window (both live in this corner, so
+ // the panel would cover the notes). Right click: the menu, any time.
tray.MouseUp += (_, e) =>
{
- if (e.Button == Forms.MouseButtons.Left) Dispatch.BeginInvoke(ShowFlyout);
+ if (e.Button == Forms.MouseButtons.Left) Dispatch.BeginInvoke(() => { if (Listen.Listening && Settings.View == "notes") ToggleNotes(); else ShowFlyout(); });
else if (e.Button == Forms.MouseButtons.Right) Dispatch.BeginInvoke(ShowMenu);
};
tray.BalloonTipClicked += (_, _) => Dispatch.BeginInvoke(() => { balloonClicked?.Invoke(); balloonClicked = null; });
@@ -187,28 +188,29 @@ sealed class Controller
menuHost ??= new Window { WindowStyle = WindowStyle.None, AllowsTransparency = true, Background = System.Windows.Media.Brushes.Transparent, ShowInTaskbar = false, Width = 1, Height = 1, Left = -10000, Top = -10000, Topmost = true };
menuHost.Show();
menuHost.Activate();
- var menu = new ContextMenu { Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint, FontFamily = Palette.Font };
- MenuItem Item(string label, string? icon, Action act, string? keys = null, bool fill = false)
+ var menu = new ContextMenu { Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint, FontFamily = Palette.Font, MinWidth = 260 };
+ MenuItem Item(string label, Action act, string? keys = null, System.Windows.Media.Brush? ink = null)
{
var item = new MenuItem { Header = label, InputGestureText = keys ?? "" };
- if (icon is not null) item.Icon = Ui.Icon(icon, 16, Palette.Ink, fill);
+ if (ink is not null) item.Foreground = ink;
item.Click += (_, _) => act();
return item;
}
- menu.Items.Add(Listen.Listening
- ? Item(L("结束"), Icons.Stop, RequestStop, Hotkey.Label, fill: true)
- : Item(L("开始听"), Icons.Wave, () => _ = ToggleListening(), Hotkey.Label));
- menu.Items.Add(new Separator());
- menu.Items.Add(Item(L("显示纪要"), Icons.Notes, ShowNotes));
- menu.Items.Add(Settings.View == "subtitles" ? Item(L("换成纪要"), Icons.Notes, () => SetView("notes")) : Item(L("换成字幕条"), Icons.Subtitles, () => SetView("subtitles")));
- var share = new MenuItem { Header = L("共享屏幕时让对方看到"), IsCheckable = true, IsChecked = Settings.ShowInCapture, Icon = Ui.Icon(Icons.Eye, 16, Palette.Ink) };
- share.Click += (_, _) => SetShowInCapture(share.IsChecked);
- menu.Items.Add(share);
+ // The Mac's status menu: where it stands, then what to do, then the windows, then 退出.
+ if (Listen.Listening && Listen.SessionId is { } sid && Store.Get(sid) is { } live)
+ {
+ var head = new MenuItem { Header = Ui.Row(8, Ui.Dot(Palette.Live, 6), Ui.Text($"{L("正在听")} · {Languages.Clock((DateTimeOffset.Now - live.StartedAt).TotalSeconds)}", 13, Palette.Secondary, wrap: false)), IsEnabled = false };
+ menu.Items.Add(head);
+ menu.Items.Add(Item(L("结束"), RequestStop, Hotkey.Label.Replace('+', ' '), Palette.AccentText));
+ if (Settings.View == "notes") menu.Items.Add(NotesVisible ? Item(L("隐藏纪要窗"), ToggleNotes) : Item(L("显示纪要"), ShowNotes));
+ }
+ else menu.Items.Add(Item(L("开始听"), () => _ = ToggleListening(), Hotkey.Label.Replace('+', ' ')));
+ menu.Items.Add(Settings.View == "subtitles" ? Item(L("换成纪要"), () => SetView("notes")) : Item(L("换成字幕条"), () => SetView("subtitles")));
menu.Items.Add(new Separator());
- menu.Items.Add(Item(L("查看记录"), Icons.List, () => ShowRecords()));
- menu.Items.Add(Item(L("打开设置"), Icons.Gear, ShowSettings));
+ menu.Items.Add(Item(L("会议记录"), () => ShowRecords()));
+ menu.Items.Add(Item(L("设置"), ShowSettings));
menu.Items.Add(new Separator());
- menu.Items.Add(Item(L("退出"), Icons.Power, () => _ = Quit()));
+ menu.Items.Add(Item(L("退出知了"), () => _ = Quit()));
menu.Closed += (_, _) => menuHost.Hide();
menu.IsOpen = true;
}
@@ -452,6 +454,21 @@ sealed class Controller
// MARK: Windows
+ /// The tray icon while listening: the notes window comes and goes.
+ public void ToggleNotes()
+ {
+ if (NotesVisible) notesWindow!.Hide(); else ShowNotes();
+ Changed();
+ }
+
+ /// The first time a window's × is clicked: closing it doesn't quit, Cicada stays in the tray.
+ public void WindowClosed()
+ {
+ if (Settings.TrayHintShown) return;
+ Settings.TrayHintShown = true; Settings.Save();
+ Toast(L("知了还在任务栏右下角"), LF("关掉窗口不会退出,按 %@ 随时开始听。", Hotkey.Label.Replace('+', ' ')));
+ }
+
public void ShowNotes()
{
notesWindow ??= new NotesWindow(this);
@@ -463,7 +480,7 @@ sealed class Controller
public void ShowRecords(string? id)
{
- if (mainWindow is null) { mainWindow = new MainWindow(this, id); mainWindow.Closed += (_, _) => mainWindow = null; }
+ if (mainWindow is null) { mainWindow = new MainWindow(this, id); mainWindow.Closed += (_, _) => { mainWindow = null; WindowClosed(); }; }
else if (id is not null) mainWindow.Select(id);
if (mainWindow.WindowState == WindowState.Minimized) mainWindow.WindowState = WindowState.Normal;
mainWindow.Show();
@@ -472,7 +489,7 @@ sealed class Controller
public void ShowSettings()
{
- if (settingsWindow is null) { settingsWindow = new SettingsWindow(this); settingsWindow.Closed += (_, _) => settingsWindow = null; }
+ if (settingsWindow is null) { settingsWindow = new SettingsWindow(this); settingsWindow.Closed += (_, _) => { settingsWindow = null; WindowClosed(); }; }
settingsWindow.Show();
settingsWindow.Activate();
}
@@ -610,7 +627,7 @@ static class DebugServer
else if (arg == "settings") app.ShowSettings();
else if (arg == "flyout") app.ShowFlyout();
else if (arg == "menu") app.ShowMenu();
- else if (arg == "onboarding") new Onboarding(app).Show();
+ else if (arg.StartsWith("onboarding")) { var o = new Onboarding(app); if (int.TryParse(arg[10..].Trim(), out var n)) o.At(n); o.Show(); }
else app.ShowNotes();
break;
case "toast": app.Toast(L("纪要整理好了"), LF("%@ · 点这里打开", "Test"), () => app.ShowRecords()); break;
diff --git a/windows/src/Cicada/MainWindow.cs b/windows/src/Cicada/MainWindow.cs
index 474ea6a..558e4d3 100644
--- a/windows/src/Cicada/MainWindow.cs
+++ b/windows/src/Cicada/MainWindow.cs
@@ -24,12 +24,15 @@ static class Records
public static string Group(Session s)
{
var d = s.StartedAt.ToLocalTime().Date;
- return d == DateTime.Today ? L("今天") : d == DateTime.Today.AddDays(-1) ? L("昨天") : L("更早");
+ var monday = DateTime.Today.AddDays(-(((int)DateTime.Today.DayOfWeek + 6) % 7));
+ return d == DateTime.Today ? L("今天") : d == DateTime.Today.AddDays(-1) ? L("昨天") : d >= monday ? L("本周") : L("更早");
}
}
-/// 会议记录: a list pane on Mica with search and day groups, and the chosen meeting on a white
-/// content layer: toolbar, 纪要 / 文字记录 tabs, and a side column for conclusions, to-dos, terms.
+/// 会议记录, as the Mac's main window with no title bar: a grey list of one-line titles grouped by
+/// day, the chosen one on a white pill, and the meeting set out like a document on one white
+/// sheet: when and how long over a big title, 纪要 / 文字记录, the conclusions and to-dos in one
+/// grey block, the summary, then the numbered topics.
sealed class MainWindow : Window
{
readonly Controller app;
@@ -47,17 +50,17 @@ sealed class MainWindow : Window
this.app = app;
selected = select;
Title = L("会议记录") + " · " + L("知了");
- Width = 1200; Height = Math.Min(780, SystemParameters.WorkArea.Height - 24); MinWidth = 960; MinHeight = 520;
+ Width = 1180; Height = Math.Min(780, SystemParameters.WorkArea.Height - 24); MinWidth = 860; MinHeight = 520;
// One white sheet, as the Mac's main window: no cards, no second layer.
Background = Palette.Surface; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
var grid = new Grid();
- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(300) });
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(260) });
grid.ColumnDefinitions.Add(new ColumnDefinition());
// The search box, with its icon and placeholder drawn over it
- var placeholder = Ui.Text(L("搜索标题、纪要和原话"), 14, Palette.Tertiary, wrap: false);
+ var placeholder = Ui.Text(L("搜索标题、纪要和原话"), 13, Palette.Secondary, wrap: false);
placeholder.IsHitTestVisible = false; placeholder.Margin = new Thickness(31, 0, 0, 0); placeholder.VerticalAlignment = VerticalAlignment.Center;
var glass = Ui.Icon(Icons.Search, 16, Palette.Secondary);
glass.HorizontalAlignment = HorizontalAlignment.Left; glass.Margin = new Thickness(10, 0, 0, 0); glass.IsHitTestVisible = false;
@@ -67,23 +70,35 @@ sealed class MainWindow : Window
search.Margin = new Thickness(22, 0, 0, 0);
placeholder.Margin = new Thickness(22, 0, 0, 0);
glass.Margin = new Thickness(0);
- var inside = new Grid { Children = { glass, search, placeholder } };
+ var ctrlF = Ui.Keycap("Ctrl F");
+ ctrlF.HorizontalAlignment = HorizontalAlignment.Right; ctrlF.IsHitTestVisible = false;
+ search.Margin = new Thickness(22, 0, 52, 0);
+ var inside = new Grid { Children = { glass, search, placeholder, ctrlF } };
+ search.TextChanged += (_, _) => ctrlF.Visibility = search.Text.Length == 0 ? Visibility.Visible : Visibility.Collapsed;
var searchBox = Ui.FieldFrame(inside, search);
- searchBox.Background = Palette.Mica; searchBox.BorderThickness = new Thickness(0); searchBox.Height = 36;
- searchBox.Margin = new Thickness(16, 16, 16, 10);
+ searchBox.Background = Palette.Selected; searchBox.BorderThickness = new Thickness(0); searchBox.Height = 36; searchBox.Padding = new Thickness(12, 0, 6, 0);
+ searchBox.Margin = new Thickness(10, 6, 10, 8);
+ System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(searchBox, true);
+ PreviewKeyDown += (_, e) =>
+ {
+ if (e.Key == System.Windows.Input.Key.F && System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Control) { search.Focus(); search.SelectAll(); e.Handled = true; }
+ else if (e.Key == System.Windows.Input.Key.Escape && search.IsKeyboardFocused) { search.Text = ""; e.Handled = true; }
+ };
- var left = new DockPanel();
+ // The list pane on the ground's grey, the logo where the title bar was.
+ var logo = AppIcon.Small(20);
+ logo.HorizontalAlignment = HorizontalAlignment.Left; logo.Margin = new Thickness(18, 14, 0, 6);
+ var left = new DockPanel { Background = Palette.Mica };
+ DockPanel.SetDock(logo, Dock.Top);
DockPanel.SetDock(searchBox, Dock.Top);
+ left.Children.Add(logo);
left.Children.Add(searchBox);
- left.Children.Add(new ScrollViewer { Content = list, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(8, 0, 8, 12) });
+ left.Children.Add(new ScrollViewer { Content = list, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(10, 0, 10, 12) });
- var right = new Border
- {
- Background = Palette.Surface, BorderBrush = Palette.Line, BorderThickness = new Thickness(1, 0, 0, 0), Child = detail,
- };
+ var right = new Border { Background = Palette.Surface, Child = detail };
Grid.SetColumn(right, 1);
grid.Children.Add(left); grid.Children.Add(right);
- Content = grid;
+ Content = Ui.Frameless(this, grid);
Refresh();
}
@@ -115,8 +130,8 @@ sealed class MainWindow : Window
if (g != group)
{
group = g;
- var h = Ui.Text(g, 12, Palette.Secondary, FontWeights.SemiBold, wrap: false);
- h.Margin = new Thickness(10, list.Children.Count == 0 ? 4 : 14, 0, 4);
+ var h = Ui.Text(g, 12, Palette.Secondary, wrap: false);
+ h.Margin = new Thickness(12, list.Children.Count == 0 ? 8 : 18, 0, 6);
list.Children.Add(h);
}
list.Children.Add(Item(s));
@@ -136,10 +151,10 @@ sealed class MainWindow : Window
var live = app.Listen.Listening && app.Listen.SessionId == s.Id;
var b = new Button
{
- Tag = s.Id, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(10, 8, 10, 8), BorderThickness = new Thickness(0),
+ Tag = s.Id, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(12, 11, 12, 11), BorderThickness = new Thickness(0),
Cursor = System.Windows.Input.Cursors.Hand, Margin = new Thickness(0, 0, 0, 2), Background = Brushes.Transparent,
- Content = Ui.Stack(2, Ui.Text(SessionStore.DisplayTitle(s), 14, Palette.Ink, FontWeights.SemiBold, wrap: false),
- Ui.Text(Records.Meta(s, app), 12, live ? Palette.AccentText : Palette.Secondary, wrap: false)),
+ Content = live ? Ui.Row(8, Ui.LiveDot(6), Ui.Text(SessionStore.DisplayTitle(s), 14, Palette.Ink, wrap: false)) : Ui.Text(SessionStore.DisplayTitle(s), 14, Palette.Ink, wrap: false),
+ ToolTip = Records.Meta(s, app),
};
b.Template = RowTemplate();
b.Click += (_, _) => { selected = s.Id; tab = "notes"; foreach (var child in list.Children.OfType<Button>()) Paint(child); ShowDetail(); };
@@ -150,8 +165,10 @@ sealed class MainWindow : Window
void Paint(Button b)
{
var on = (string)b.Tag == selected;
- // The Mac's list: the chosen meeting on the ground's grey, no shadow.
- b.Background = on ? Palette.Mica : Brushes.Transparent;
+ // The Mac's list: the chosen meeting on a white pill on the grey pane.
+ b.Background = on ? Palette.Surface : Brushes.Transparent;
+ var label = b.Content as TextBlock ?? (b.Content as Panel)?.Children.OfType<TextBlock>().FirstOrDefault();
+ if (label is not null) label.FontWeight = on ? FontWeights.Bold : FontWeights.Normal;
}
/// A list row: white and raised when chosen, a grey wash under the mouse otherwise.
@@ -167,7 +184,7 @@ sealed class MainWindow : Window
var hover = new MultiTrigger();
hover.Conditions.Add(new Condition(UIElement.IsMouseOverProperty, true));
hover.Conditions.Add(new Condition(Control.BackgroundProperty, Brushes.Transparent));
- hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Page, "bg"));
+ hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Selected, "bg"));
t.Triggers.Add(hover);
return t;
}
@@ -175,7 +192,7 @@ sealed class MainWindow : Window
static FrameworkElement Empty(string title, string hint)
{
var s = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
- var t = Ui.Text(title, 16, Palette.Ink, FontWeights.SemiBold); t.TextAlignment = TextAlignment.Center; s.Children.Add(t);
+ var t = Ui.Text(title, 16, Palette.Ink); t.TextAlignment = TextAlignment.Center; s.Children.Add(t);
if (hint.Length > 0) { var h = Ui.Text(hint, 13, Palette.Secondary); h.TextAlignment = TextAlignment.Center; h.Margin = new Thickness(0, 6, 0, 0); s.Children.Add(h); }
return s;
}
@@ -190,10 +207,21 @@ sealed class MainWindow : Window
shownKey = PageKey();
if (selected is null || app.Store.Get(selected) is not { } s) { detail.Content = Empty(L("还没有会议记录"), ""); return; }
var live = app.Listen.Listening && app.Listen.SessionId == s.Id;
- var top = new StackPanel { Margin = new Thickness(32, 24, 32, 0) };
+ var top = new StackPanel();
+
+ // When, how long, and from what into what, above the title.
+ var local = s.StartedAt.ToLocalTime();
+ var spoken = s.Lines.Select(l => l.SrcLang).FirstOrDefault(x => x is not null);
+ var into = s.Lines.Select(l => l.DstLang).FirstOrDefault(x => x is not null);
+ var meta = new List<string> { local.ToString(L("M月d日"), Culture) + " " + local.ToString("HH:mm", Culture) };
+ meta.Add(live ? L("正在听") : LF("%@ 分钟", Math.Max(1, (int)Math.Round(s.Duration.TotalMinutes))));
+ if (spoken is not null && into is not null) meta.Add($"{Ui.SpokenName(spoken)} → {Ui.TargetName(into)}");
+ top.Children.Add(Ui.Text(string.Join(" · ", meta), 13, live ? Palette.AccentText : Palette.Secondary));
- var title = Ui.Text(SessionStore.DisplayTitle(s), 26, Palette.Ink, FontWeights.Bold);
- var titleRow = Ui.Row(6, title, Ui.IconButton(Icons.Pencil, L("重命名"), () => Rename(s), Palette.Secondary, 32, 16));
+ var title = Ui.Text(SessionStore.DisplayTitle(s), 28, Palette.Ink, FontWeights.Bold);
+ var rename = Ui.IconButton(Icons.Pencil, L("重命名"), () => Rename(s), Palette.Tertiary, 30, 15);
+ var titleRow = Ui.Row(6, title, rename);
+ titleRow.Margin = new Thickness(0, 6, 0, 0);
// As the Mac's context menu: only when the notes have a name to go back to.
if ((s.Renamed ?? !s.Title.StartsWith("会议 ")) && !string.IsNullOrEmpty(s.Notes?.Title))
{
@@ -203,95 +231,145 @@ sealed class MainWindow : Window
titleRow.Children.Add(reset);
}
top.Children.Add(titleRow);
- var spoken = s.Lines.Select(l => l.SrcLang).FirstOrDefault(x => x is not null);
- var into = s.Lines.Select(l => l.DstLang).FirstOrDefault(x => x is not null);
- var meta = new List<string> { Records.Meta(s, app), LF("%@ 句", s.Lines.Count) };
- if (spoken is not null && into is not null) meta.Add($"{Ui.SpokenName(spoken)} → {Ui.TargetName(into)}");
- var metaText = Ui.Text(string.Join(" · ", meta), 13, Palette.Secondary);
- metaText.Margin = new Thickness(0, 6, 0, 0);
- top.Children.Add(metaText);
- var tools = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 14, 0, 0) };
+ // 纪要 / 文字记录 on the left, what to do with it on the right, one hairline under both.
+ var tabs = Ui.Tabs([("notes", L("纪要")), ("transcript", s.Lines.Count > 0 ? $"{L("文字记录")} {s.Lines.Count}" : L("文字记录"))], tab, t => { tab = t; ShowDetail(); }, 15);
+ var tools = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Top };
var hasNotes = s.Notes is { IsEmpty: false };
- if (!hasNotes && !live) tools.Children.Add(Ui.Button(L("生成纪要"), () => _ = app.Notes.Generate(s.Id), Ui.Kind.Primary));
+ if (!hasNotes && !live) tools.Children.Add(Small(Ui.Button(L("生成纪要"), () => _ = app.Notes.Generate(s.Id), Ui.Kind.Primary, height: 32)));
else
{
Button? copy = null;
- copy = Ui.Button(L("复制纪要"), () =>
+ copy = Small(Ui.Button(L("复制纪要"), () =>
{
try { Clipboard.SetText(SessionStore.NotesMarkdown(s)); } catch (Exception e) { Log.Debug($"copy: failed {e.GetType().Name}"); return; }
Flash(copy!, L("已复制"));
- }, Ui.Kind.Standard, Icons.Copy);
+ }, Ui.Kind.Standard, height: 32));
copy.IsEnabled = hasNotes;
tools.Children.Add(copy);
}
- tools.Children.Add(Spaced(Ui.Button(L("导出"), () => Export(s), Ui.Kind.Subtle, Icons.Export), 4));
- var delete = Ui.Button(L("删除"), () => Delete(s), Ui.Kind.Subtle, Icons.Trash);
- delete.IsEnabled = !live;
- tools.Children.Add(Spaced(delete, 4));
- top.Children.Add(tools);
-
- var tabs = Ui.Tabs([("notes", L("纪要")), ("transcript", L("文字记录"))], tab, t => { tab = t; ShowDetail(); });
- tabs.Margin = new Thickness(-12, 10, 0, 0);
- top.Children.Add(tabs);
-
- var dock = new DockPanel();
- DockPanel.SetDock(top, Dock.Top);
- dock.Children.Add(top);
- var rule = new Border { Height = 1, Background = Palette.StrokeSoft };
- DockPanel.SetDock(rule, Dock.Top);
- dock.Children.Add(rule);
- var scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(32, 20, 24, 32) };
- scroll.Content = tab == "transcript" ? Transcript(s, scroll) : Notes(s, live);
- dock.Children.Add(scroll);
- detail.Content = dock;
+ tools.Children.Add(Spaced(Small(Ui.Button(L("导出…"), () => Export(s), Ui.Kind.Standard, height: 32)), 8));
+ Button? more = null;
+ more = Ui.Button("···", () =>
+ {
+ var menu = new ContextMenu { PlacementTarget = more, Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom, FontFamily = Palette.Font };
+ var r = new MenuItem { Header = L("重命名") }; r.Click += (_, _) => Rename(s); menu.Items.Add(r);
+ var d = new MenuItem { Header = L("删除"), IsEnabled = !live, Foreground = Palette.Danger }; d.Click += (_, _) => Delete(s); menu.Items.Add(d);
+ menu.IsOpen = true;
+ }, Ui.Kind.Standard, height: 32);
+ more.MinWidth = 0; more.Width = 36; more.Padding = new Thickness(0);
+ tools.Children.Add(Spaced(more, 8));
+ var bar = Ui.Spread(tabs, tools);
+ bar.Margin = new Thickness(0, 18, 0, 0);
+ top.Children.Add(bar);
+ top.Children.Add(new Border { Height = 1, Background = Palette.Line });
+
+ // One centred column, like a page: content runs into the old title bar's height.
+ var page = new StackPanel { MaxWidth = 700, Margin = new Thickness(48, 56, 48, 48) };
+ page.Children.Add(top);
+ var body = tab == "transcript" ? Transcript(s) : Notes(s, live);
+ body.Margin = new Thickness(0, 28, 0, 0);
+ page.Children.Add(body);
+ var scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Content = page };
+ if (pendingJump is { } jump) { pendingJump = null; jump(scroll); }
+ detail.Content = scroll;
}
+ static Button Small(Button b) { b.MinWidth = 0; b.Padding = new Thickness(12, 0, 12, 0); return b; }
+
+ Action<ScrollViewer>? pendingJump;
+
static T Spaced<T>(T e, double left) where T : FrameworkElement { e.Margin = new Thickness(left, 0, 0, 0); return e; }
FrameworkElement Notes(Session s, bool live)
{
if (s.Notes is not { IsEmpty: false } n)
return Empty(live ? L("纪要会在会议进行中自动生成") : L("生成纪要"), "");
- var article = new StackPanel { MaxWidth = 680, HorizontalAlignment = HorizontalAlignment.Left };
- if (n.Summary.Length > 0) article.Children.Add(Ui.Text(n.Summary, 15, Palette.Body));
- foreach (var t in n.Topics)
+ var article = new StackPanel();
+ void Jump(double t) { tab = "transcript"; jumpTo = t; ShowDetail(); }
+
+ // The conclusions first, in one quiet grey block; to-dos with an open circle.
+ var items = n.Conclusions.Select(c => (c, todo: false)).Concat(n.Todos.Select(t => (c: t, todo: true))).ToList();
+ if (items.Count > 0)
{
- var start = t.Start;
- var time = Ui.LinkText(Languages.Clock(start), () => { tab = "transcript"; jumpTo = start; ShowDetail(); }, 13);
- var head = Ui.Row(10, time, Ui.Text(t.Title, 16, Palette.Ink, FontWeights.SemiBold));
- head.Margin = new Thickness(0, 20, 0, 0);
- article.Children.Add(head);
- if (t.Summary.Length > 0) article.Children.Add(Gap(Ui.Text(t.Summary, 14, Palette.Secondary), 6));
- foreach (var p in t.Points) article.Children.Add(Gap(Ui.Text("· " + p, 14, Palette.Body), 4));
+ var block = new StackPanel();
+ block.Children.Add(Ui.Text(n.Todos.Count == 0 ? L("结论") : L("结论和待办"), 13, Palette.Secondary));
+ foreach (var (item, todo) in items)
+ {
+ var row = new DockPanel { Margin = new Thickness(0, 12, 0, 0) };
+ FrameworkElement mark = todo
+ ? new System.Windows.Shapes.Ellipse { Width = 11, Height = 11, Stroke = Palette.Live, StrokeThickness = 1.5 }
+ : new System.Windows.Shapes.Ellipse { Width = 5, Height = 5, Fill = Palette.Body };
+ var markBox = new Border { Width = 26, Height = 20, Child = mark, VerticalAlignment = VerticalAlignment.Top };
+ mark.HorizontalAlignment = HorizontalAlignment.Left; mark.VerticalAlignment = VerticalAlignment.Center;
+ DockPanel.SetDock(markBox, Dock.Left);
+ row.Children.Add(markBox);
+ if (item.T is { } t)
+ {
+ var at = Ui.LinkText(Languages.Clock(t), () => Jump(t), 13);
+ at.VerticalAlignment = VerticalAlignment.Top; at.Margin = new Thickness(16, 1, 0, 0);
+ DockPanel.SetDock(at, Dock.Right);
+ row.Children.Add(at);
+ }
+ row.Children.Add(Ui.Text(item.Text + (item.Owner is { Length: > 0 } o ? $"({o})" : ""), 15, item.Support == 0 ? Palette.Tertiary : Palette.Ink));
+ block.Children.Add(row);
+ }
+ article.Children.Add(new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(16), Padding = new Thickness(26, 22, 26, 22), Child = block, Margin = new Thickness(0, 0, 0, 32) });
}
- var rail = new StackPanel();
- if (n.Conclusions.Count > 0) rail.Children.Add(RailCard(L("结论"), n.Conclusions.Select(c => (FrameworkElement)Ui.Text(c.Text, 14, Palette.Ink))));
- if (n.Todos.Count > 0) rail.Children.Add(RailCard($"{L("待办")} · {n.Todos.Count}", n.Todos.Select(NotesWindow.Todo)));
- var terms = NoteTerm.Ordered(n.Terms).Take(8).ToList();
- if (terms.Count > 0) rail.Children.Add(RailCard(L("术语"), terms.Select(t => (FrameworkElement)Ui.Text(t.Note.Length > 0 ? $"{t.Name} · {t.Note}" : t.Name, 13, Palette.Body))));
+ if (n.Summary.Length > 0)
+ {
+ var sum = Ui.Text(n.Summary, 15, Palette.Body);
+ sum.LineHeight = 28;
+ article.Children.Add(sum);
+ }
- var grid = new Grid();
- grid.ColumnDefinitions.Add(new ColumnDefinition());
- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(rail.Children.Count > 0 ? 300 : 0) });
- Grid.SetColumn(rail, 1);
- rail.Margin = new Thickness(24, 0, 0, 0);
- grid.Children.Add(article); grid.Children.Add(rail);
- return grid;
- }
+ // The topics as numbered rows between hairlines.
+ if (n.Topics.Count > 0)
+ {
+ var label = Ui.Text(L("议题"), 13, Palette.Secondary);
+ label.Margin = new Thickness(0, 36, 0, 10);
+ article.Children.Add(label);
+ for (int i = 0; i < n.Topics.Count; i++)
+ {
+ var t = n.Topics[i];
+ article.Children.Add(new Border { Height = 1, Background = Palette.Line });
+ var num = Ui.Text($"{i + 1:00}", 14, Palette.AccentText, wrap: false);
+ num.Width = 40; num.VerticalAlignment = VerticalAlignment.Top; num.Margin = new Thickness(0, 2, 0, 0);
+ var start = t.Start;
+ var at = Ui.LinkText(Languages.Clock(start), () => Jump(start), 13);
+ at.VerticalAlignment = VerticalAlignment.Top; at.Margin = new Thickness(16, 2, 0, 0);
+ var text = new StackPanel();
+ var head = Ui.Row(8, Ui.Text(t.Title, 17, Palette.Ink, FontWeights.Bold));
+ if (live && i == n.Topics.Count - 1) head.Children.Add(Spaced(Ui.Badge(L("正在讲")), 8));
+ text.Children.Add(head);
+ if (t.Summary.Length > 0) text.Children.Add(Gap(Ui.Text(t.Summary, 14, Palette.Body), 8));
+ foreach (var p in t.Points) text.Children.Add(Gap(Ui.Text("· " + p, 14, Palette.Secondary), 4));
+ var row = new DockPanel { Margin = new Thickness(0, 18, 0, 20) };
+ DockPanel.SetDock(num, Dock.Left); DockPanel.SetDock(at, Dock.Right);
+ row.Children.Add(num); row.Children.Add(at); row.Children.Add(text);
+ article.Children.Add(row);
+ }
+ article.Children.Add(new Border { Height = 1, Background = Palette.Line });
+ }
- static FrameworkElement RailCard(string title, IEnumerable<FrameworkElement> items)
- {
- var s = new StackPanel();
- s.Children.Add(Ui.Text(title, 13, Palette.Body, FontWeights.SemiBold));
- foreach (var i in items) s.Children.Add(Gap(i, 10));
- return new Border { Background = Palette.Page, BorderBrush = Palette.Line, BorderThickness = new Thickness(0), CornerRadius = new CornerRadius(14), Padding = new Thickness(16, 14, 16, 14), Margin = new Thickness(0, 0, 0, 16), Child = s };
+ var terms = NoteTerm.Ordered(n.Terms).Take(12).ToList();
+ if (terms.Count > 0)
+ {
+ var label = Ui.Text(L("人名和术语"), 13, Palette.Secondary);
+ label.Margin = new Thickness(0, 36, 0, 10);
+ article.Children.Add(label);
+ var chips = new WrapPanel();
+ foreach (var t in terms)
+ chips.Children.Add(new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(8), Padding = new Thickness(10, 5, 10, 6), Margin = new Thickness(0, 0, 8, 8), Child = Ui.Text(t.Note.Length > 0 ? $"{t.Name} · {t.Note}" : t.Name, 13, Palette.Body, wrap: false) });
+ article.Children.Add(chips);
+ }
+ return article;
}
- FrameworkElement Transcript(Session s, ScrollViewer scroll)
+ FrameworkElement Transcript(Session s)
{
- var body = new StackPanel { MaxWidth = 760, HorizontalAlignment = HorizontalAlignment.Left };
+ var body = new StackPanel();
FrameworkElement? target = null;
// The line nearest the topic's time (older notes may hold a time no line has).
var nearest = jumpTo is { } t0 && s.Lines.Count > 0 ? s.Lines.MinBy(l => Math.Abs(l.T - t0)) : null;
@@ -306,13 +384,16 @@ sealed class MainWindow : Window
// A topic's time opens the transcript at what was said then, marked for a moment.
row.Background = Palette.AccentPale;
// Measured once laid out: before that every row is at the top.
- void Jump(object? _, RoutedEventArgs __)
+ pendingJump = scroll =>
{
- row.Loaded -= Jump;
- var y = row.TransformToAncestor(body).Transform(new Point(0, 0)).Y;
- scroll.ScrollToVerticalOffset(Math.Max(0, y - 24));
- }
- row.Loaded += Jump;
+ void Jump(object? _, RoutedEventArgs __)
+ {
+ row.Loaded -= Jump;
+ var y = row.TransformToAncestor(scroll).Transform(new Point(0, 0)).Y;
+ scroll.ScrollToVerticalOffset(Math.Max(0, scroll.VerticalOffset + y - 24));
+ }
+ row.Loaded += Jump;
+ };
var fade = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
fade.Tick += (_, _) => { row.Background = Brushes.Transparent; fade.Stop(); };
fade.Start();
diff --git a/windows/src/Cicada/NotesWindow.cs b/windows/src/Cicada/NotesWindow.cs
index aebabc7..7d2027c 100644
--- a/windows/src/Cicada/NotesWindow.cs
+++ b/windows/src/Cicada/NotesWindow.cs
@@ -167,7 +167,7 @@ sealed class NotesWindow : Window
{
builtFor = mode; headerKey = tabsKey = barsKey = null;
header = new ContentControl(); bars = new ContentControl(); ending = new ContentControl(); endingKey = null; live = new ContentControl(); tabs = new ContentControl(); footer = new ContentControl();
- scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(16, 14, 12, 16) };
+ scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(20, 16, 16, 12) };
Content = Subtitles ? SubtitleFrame() : PanelFrame();
}
var key = $"{app.Listen.Listening}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";
@@ -195,15 +195,18 @@ sealed class NotesWindow : Window
{
var dock = new DockPanel();
void Top(UIElement e) { DockPanel.SetDock(e, Dock.Top); dock.Children.Add(e); }
+ // The Mac's layout: the header, 纪要 / 文字记录 as a two-part switch, the notes, and the
+ // sentence being said now on a dark card along the bottom, where the eye rests.
Top(header);
Top(ending);
Top(bars);
- Top(live);
- tabs.Margin = new Thickness(12, 10, 12, 0);
+ tabs.Margin = new Thickness(12, 0, 12, 0);
Top(tabs);
- Top(new Border { Height = 1, Background = Palette.StrokeSoft, Margin = new Thickness(0, 4, 0, 0) });
DockPanel.SetDock(footer, Dock.Bottom);
dock.Children.Add(footer);
+ live.Margin = new Thickness(12, 8, 12, 0);
+ DockPanel.SetDock(live, Dock.Bottom);
+ dock.Children.Add(live);
dock.Children.Add(scroll);
return Ui.Floating(dock, Palette.Surface);
}
@@ -214,17 +217,22 @@ sealed class NotesWindow : Window
var session = listen.SessionId is { } id ? app.Store.Get(id) : null;
if (Subtitles)
{
- var buttons = new StackPanel { Orientation = Orientation.Horizontal };
- buttons.Children.Add(Ui.IconButton(Icons.Notes, L("换成纪要"), () => app.SetView("notes"), Brushes.White, 40, 18, onDark: true));
- if (listen.Listening) buttons.Children.Add(Ui.IconButton(Icons.Stop, L("结束"), app.RequestStop, new SolidColorBrush(Color.FromRgb(0xFF, 0x9B, 0x78)), 40, 16, fill: true, onDark: true));
- buttons.Children.Add(Ui.IconButton(Icons.Close, L("收起(继续听)"), Collapse, Brushes.White, 40, 14, onDark: true));
+ var buttons = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Top };
+ buttons.Children.Add(Ui.IconButton(Icons.Notes, L("换成纪要"), () => app.SetView("notes"), Palette.NightText, 32, 16, onDark: true));
+ if (listen.Listening)
+ {
+ var stop = Ui.IconButton("M7,7 H13 V13 H7 Z", L("结束"), app.RequestStop, NightAccent, 32, 14, fill: true, onDark: true);
+ stop.Background = new SolidColorBrush(Color.FromArgb(0x1F, 0xFF, 0xFF, 0xFF));
+ buttons.Children.Add(Gap(stop, 6));
+ }
+ else buttons.Children.Add(Gap(Ui.IconButton(Icons.Close, L("收起(继续听)"), Collapse, Palette.NightText, 32, 14, onDark: true), 6));
return buttons;
}
var left = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center };
if (listen.Listening && session is not null)
{
left.Children.Add(Ui.LiveDot());
- left.Children.Add(Gap(Ui.Text(L("正在听"), 14, Palette.Ink, FontWeights.SemiBold, wrap: false), 8));
+ left.Children.Add(Gap(Ui.Text(L("正在听"), 14, Palette.Ink, FontWeights.Bold, wrap: false), 8));
Detach(clockText);
clockText.FontSize = 13; clockText.Foreground = Palette.Secondary; clockText.HorizontalAlignment = HorizontalAlignment.Left;
left.Children.Add(Gap(clockText, 8));
@@ -232,19 +240,19 @@ sealed class NotesWindow : Window
else
{
left.Children.Add(AppIcon.Small(18));
- left.Children.Add(Gap(Ui.Text(L("知了"), 14, Palette.Ink, FontWeights.SemiBold, wrap: false), 8));
+ left.Children.Add(Gap(Ui.Text(L("知了"), 14, Palette.Ink, FontWeights.Bold, wrap: false), 8));
}
- if (app.Settings.ShowInCapture) left.Children.Add(Gap(Ui.Badge(L("对方可见")), 8));
-
var right = new StackPanel { Orientation = Orientation.Horizontal };
- right.Children.Add(Ui.IconButton(Icons.Subtitles, L("换成字幕条"), () => app.SetView("subtitles"), Palette.Body, 40, 18));
- right.Children.Add(listen.Listening
- ? Gap(Ui.Button(L("结束"), app.RequestStop, Ui.Kind.Pale, Icons.Stop, 36, iconFill: true), 2)
- : Gap(Ui.Button(L("开始听"), () => _ = app.ToggleListening(), Ui.Kind.Accent, Icons.Wave, 36), 2));
- right.Children.Add(Gap(Ui.IconButton(Icons.Close, L("收起(继续听)"), Collapse, Palette.Body, 40, 14), 2));
+ right.Children.Add(Ui.IconButton(Icons.Subtitles, L("换成字幕条"), () => app.SetView("subtitles"), Palette.Body, 34, 16));
+ var main = listen.Listening
+ ? Ui.Button(L("结束"), app.RequestStop, Ui.Kind.Pale, Icons.Stop, 32, iconFill: true)
+ : Ui.Button(L("开始听"), () => _ = app.ToggleListening(), Ui.Kind.Accent, Icons.Wave, 32);
+ main.MinWidth = 0; main.Padding = new Thickness(12, 0, 12, 0);
+ right.Children.Add(Gap(main, 8));
+ right.Children.Add(Gap(Ui.IconButton("M5,10 H15", L("收起(继续听)"), Collapse, Palette.Body, 34, 16), 4));
var row = Ui.Spread(left, right);
row.Height = 56;
- row.Margin = new Thickness(16, 0, 8, 0);
+ row.Margin = new Thickness(18, 0, 10, 0);
return row;
}
@@ -277,10 +285,8 @@ sealed class NotesWindow : Window
Add(Ui.InfoBar(Ui.Severity.Warning, null, L("这轮没整理好,下一轮会自动重试。")));
break;
}
- if (app.Settings.ShowInCapture)
- Add(Ui.InfoBar(Ui.Severity.Warning, null, L("共享屏幕时,对方能看到这个窗口。"),
- Ui.LinkText(L("改回只有我看得到"), () => app.SetShowInCapture(false))));
- else if (!hiddenFromCapture)
+ // Shown to others on purpose: the footer's 对方可见 says so. Not hidden though asked: a warning.
+ if (!app.Settings.ShowInCapture && !hiddenFromCapture)
Add(Ui.InfoBar(Ui.Severity.Warning, null, L("Windows 没能把这个窗口从屏幕共享里藏起来,对方可能看得到。")));
return stack;
}
@@ -293,7 +299,8 @@ sealed class NotesWindow : Window
return Languages.Clock(lines is not null && covered > 0 && covered <= lines.Count ? lines[covered - 1].T : 0);
}
- /// The newest line: the original small, its translation large, then "在听下一句" while Ming works.
+ /// The newest line on the Mac's dark card: who in their colour and 正在说 while Ming works on the
+ /// next, the original small, its translation large and bold.
FrameworkElement LiveCard()
{
var listen = app.Listen;
@@ -301,34 +308,30 @@ sealed class NotesWindow : Window
var stack = new StackPanel();
if (line is null)
{
- if (listen.Listening)
- stack.Children.Add(Ui.Row(12, Ui.Icon(Icons.Wave, 22, Palette.Secondary, stroke: 1.6),
- Ui.Stack(2, Ui.Text(L("等有人说话"), 14, Palette.Ink, FontWeights.SemiBold), Ui.Helper(L("电脑里一有人声,字幕就出来")))));
- else stack.Children.Add(Ui.Text(L("点“开始听”,电脑里播放的声音会变成双语字幕和纪要"), 13, Palette.Secondary));
+ stack.Children.Add(Ui.Text(listen.Listening ? L("等有人说话") : L("点“开始听”,电脑里播放的声音会变成双语字幕和纪要"), 14, Brushes.White, listen.Listening ? FontWeights.Bold : FontWeights.Normal));
+ if (listen.Listening) stack.Children.Add(Gap(Ui.Text(L("电脑里一有人声,字幕就出来"), 12, Palette.NightText), 4, top: true));
}
else
{
var lines = app.Store.Get(listen.SessionId!)?.Lines ?? [];
var number = app.Settings.SpeakerVoices && line.Speaker == "them" && SpeakerLabels.Numbers(lines).TryGetValue(line.Id, out var n) ? n : (int?)null;
- var who = line.Speaker == "me" ? L("你") : number is { } k ? $"{LF("说话人 %lld", k)} · {Ui.SpokenName(line.SrcLang)}" : Ui.SpokenName(line.SrcLang);
- var whoInk = line.Speaker == "me" ? Palette.AccentText : number is { } k2 ? Palette.Speaker(k2) : Palette.Tertiary;
- stack.Children.Add(Ui.Text($"{who} · {Languages.Clock(line.T)}", 12, whoInk, wrap: false));
- if (line.Dst is not null && line.Dst != line.Src) stack.Children.Add(Gap(Ui.Text(line.Src, 13, Palette.Secondary), 4, top: true));
- stack.Children.Add(Gap(Ui.Text(line.Dst ?? line.Src, 17, Palette.Ink, FontWeights.SemiBold), 2, top: true));
- if (listen.Listening && listen.Pending > 0)
- stack.Children.Add(Gap(Ui.Row(6, Ui.LiveDot(4), Ui.Text(L("在听下一句"), 12, Palette.Tertiary, wrap: false)), 6, top: true));
+ var who = line.Speaker == "me" ? L("你") : number is { } k ? LF("说话人 %lld", k) : Ui.SpokenName(line.SrcLang);
+ var whoRow = Ui.Row(8, Ui.Text(who, 12, NightAccent, wrap: false));
+ whoRow.Children.Add(Gap(Ui.Text(listen.Listening && listen.Pending > 0 ? L("正在说") : Languages.Clock(line.T), 12, Palette.NightText, wrap: false), 8));
+ stack.Children.Add(whoRow);
+ if (line.Dst is not null && line.Dst != line.Src) stack.Children.Add(Gap(Ui.Text(line.Src, 13, NightBody), 6, top: true));
+ stack.Children.Add(Gap(Ui.Text(line.Dst ?? line.Src, 16, Brushes.White, FontWeights.Bold), 6, top: true));
}
- // Room for a two-line translation, so the tabs below don't jump as lines come and go.
- return new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(12), Padding = new Thickness(14, 12, 14, 12), Margin = new Thickness(12, 0, 12, 0), Child = stack, MinHeight = 126 };
+ return new Border { Background = Palette.Night, CornerRadius = new CornerRadius(14), Padding = new Thickness(16, 14, 16, 14), Child = stack, MinHeight = 96 };
}
+ /// Text on the dark card: the accent lifted for contrast, and the original a light grey.
+ static readonly SolidColorBrush NightAccent = new(Color.FromRgb(0xFF, 0x8A, 0x5C)), NightBody = new(Color.FromRgb(0xD9, 0xDC, 0xE1));
+
FrameworkElement TabRow()
{
var count = app.Listen.SessionId is { } id ? app.Store.Get(id)?.Lines.Count ?? 0 : 0;
- var tabsRow = Ui.Tabs([("notes", L("纪要")), ("transcript", count > 0 ? $"{L("文字记录")} {count}" : L("文字记录"))], tab, t => { tab = t; Render(); });
- Detach(dueText);
- dueText.VerticalAlignment = VerticalAlignment.Center;
- return Ui.Spread(tabsRow, dueText);
+ return Ui.Segmented([("notes", L("纪要")), ("transcript", count > 0 ? $"{L("文字记录")} {count}" : L("文字记录"))], tab, t => { tab = t; Render(); }, fill: true, height: 30);
}
string? Due()
@@ -353,27 +356,35 @@ sealed class NotesWindow : Window
_ => app.Listen.Listening ? (L("纪要会在会议进行中自动生成"), "") : ("", ""),
};
var empty = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 48, 0, 0) };
- if (title.Length > 0) { var t = Ui.Text(title, 14, Palette.Body, FontWeights.SemiBold); t.TextAlignment = TextAlignment.Center; empty.Children.Add(t); }
+ if (title.Length > 0) { var t = Ui.Text(title, 14, Palette.Body); t.TextAlignment = TextAlignment.Center; empty.Children.Add(t); }
if (hint.Length > 0) { var h = Ui.Text(hint, 13, Palette.Secondary); h.TextAlignment = TextAlignment.Center; empty.Children.Add(Gap(h, 4, top: true)); }
body.Children.Add(empty);
return body;
}
- if (notes.Title is { Length: > 0 } title2) body.Children.Add(Ui.Text(title2, 18, Palette.Ink, FontWeights.SemiBold));
- if (notes.Summary.Length > 0) body.Children.Add(Gap(Ui.Text(notes.Summary, 14, Palette.Body), 6, top: true));
- foreach (var topic in notes.Topics)
+ if (notes.Title is { Length: > 0 } title2) body.Children.Add(Ui.Text(title2, 18, Palette.Ink, FontWeights.Bold));
+ if (notes.Summary.Length > 0) { var sum = Ui.Text(notes.Summary, 14, Palette.Body); sum.LineHeight = 24; body.Children.Add(Gap(sum, 8, top: true)); }
+ for (int i = 0; i < notes.Topics.Count; i++)
{
- body.Children.Add(Gap(Ui.Row(8, Ui.Text(Languages.Clock(topic.Start), 12, Palette.AccentText, FontWeights.SemiBold, wrap: false),
- Ui.Text(topic.Title, 14, Palette.Ink, FontWeights.SemiBold)), 18, top: true));
- foreach (var p in topic.Points) body.Children.Add(Gap(Bullet(p), 4, top: true));
+ var topic = notes.Topics[i];
+ var time = Ui.Text(Languages.Clock(topic.Start), 12, Palette.AccentText, wrap: false);
+ time.Width = 40; time.Margin = new Thickness(0, 2, 0, 0); time.VerticalAlignment = VerticalAlignment.Top;
+ var head = Ui.Row(8, Ui.Text(topic.Title, 15, Palette.Ink));
+ if (app.Listen.Listening && i == notes.Topics.Count - 1) head.Children.Add(Gap(Ui.Badge(L("正在讲")), 8));
+ var points = new StackPanel { Children = { head } };
+ foreach (var p in topic.Points) points.Children.Add(Gap(Ui.Text(p, 13, Palette.Secondary), 4, top: true));
+ var dock = new DockPanel();
+ DockPanel.SetDock(time, Dock.Left);
+ dock.Children.Add(time); dock.Children.Add(points);
+ body.Children.Add(Gap(dock, 18, top: true));
}
if (notes.Conclusions.Count > 0)
{
- body.Children.Add(Gap(Ui.Text(L("结论"), 13, Palette.Secondary, FontWeights.SemiBold), 18, top: true));
+ body.Children.Add(Gap(Ui.Text(L("结论"), 13, Palette.Secondary), 18, top: true));
foreach (var c in notes.Conclusions) body.Children.Add(Gap(Bullet(c.Text), 4, top: true));
}
if (notes.Todos.Count > 0)
{
- body.Children.Add(Gap(Ui.Text(L("待办"), 13, Palette.Secondary, FontWeights.SemiBold), 18, top: true));
+ body.Children.Add(Gap(Ui.Text(L("待办"), 13, Palette.Secondary), 18, top: true));
foreach (var todo in notes.Todos) body.Children.Add(Gap(Todo(todo), 6, top: true));
}
return body;
@@ -410,44 +421,34 @@ sealed class NotesWindow : Window
}
}
+ /// One line of the transcript as on the Mac: who (in their colour) and when, the original in
+ /// grey, the translation in ink.
internal static FrameworkElement TranscriptRow(TranscriptLine l, string? who = null, Brush? ink = null)
{
- var row = new DockPanel { Margin = new Thickness(0, 0, 0, 12) };
- var time = Ui.Text(Languages.Clock(l.T), 12, Palette.AccentText, FontWeights.SemiBold, wrap: false);
- time.Width = 48; time.VerticalAlignment = VerticalAlignment.Top; time.Margin = new Thickness(0, 2, 0, 0);
- DockPanel.SetDock(time, Dock.Left);
- row.Children.Add(time);
- var text = new StackPanel();
- if (who is not null) text.Children.Add(Ui.Text(who, 12, ink ?? Palette.Secondary, FontWeights.SemiBold, wrap: false));
- text.Children.Add(Ui.Text(l.Src, 14, Palette.Ink));
- if (!string.IsNullOrEmpty(l.Dst) && l.Dst != l.Src) text.Children.Add(Gap(Ui.Text(l.Dst, 13, Palette.Secondary), 2, top: true));
- row.Children.Add(text);
- return row;
+ var text = new StackPanel { Margin = new Thickness(0, who is null ? 0 : 6, 0, 12) };
+ var head = Ui.Row(8, Ui.Text(Languages.Clock(l.T), 12, Palette.Tertiary, wrap: false));
+ if (who is not null) head.Children.Insert(0, Ui.Text(who, 12, ink ?? Palette.Secondary, wrap: false));
+ if (head.Children.Count > 1) ((FrameworkElement)head.Children[1]).Margin = new Thickness(8, 0, 0, 0);
+ text.Children.Add(head);
+ var translated = !string.IsNullOrEmpty(l.Dst) && l.Dst != l.Src;
+ text.Children.Add(Gap(Ui.Text(l.Src, translated ? 13 : 15, translated ? Palette.Secondary : Palette.Ink), 3, top: true));
+ if (translated) text.Children.Add(Gap(Ui.Text(l.Dst!, 15, Palette.Ink), 2, top: true));
+ return text;
}
+ /// Who can see this window, and when the notes change next.
FrameworkElement Footer()
{
var visible = app.Settings.ShowInCapture || !hiddenFromCapture;
- var left = Ui.Row(6, Ui.Icon(visible ? Icons.Eye : Icons.EyeOff, 16, visible ? Palette.AccentText : Palette.Secondary),
- Ui.Text(visible ? L("对方可见") : L("屏幕共享里看不到"), 12, visible ? Palette.AccentText : Palette.Secondary, wrap: false));
- Button? targetButton = null;
- targetButton = Ui.Button($"{L("翻译成")} {Ui.TargetName(app.Settings.TargetCode)}", () =>
- {
- var menu = new ContextMenu { PlacementTarget = targetButton, Placement = System.Windows.Controls.Primitives.PlacementMode.Top };
- foreach (var (value, label) in Ui.TargetOptions())
- {
- var item = new MenuItem { Header = label, IsCheckable = true, IsChecked = value == app.Settings.Target };
- item.Click += (_, _) => app.SetTarget(value);
- menu.Items.Add(item);
- }
- menu.IsOpen = true;
- }, Ui.Kind.Subtle, Icons.Globe, height: 32);
- targetButton.MinWidth = 0;
- targetButton.Padding = new Thickness(10, 0, 10, 0);
- var row = Ui.Spread(left, targetButton);
- row.Height = 44;
- row.Margin = new Thickness(14, 0, 8, 0);
- return new Border { BorderBrush = Palette.StrokeSoft, BorderThickness = new Thickness(0, 1, 0, 0), Child = row };
+ FrameworkElement left = Ui.Row(6, Ui.Icon(visible ? Icons.Eye : Icons.EyeOff, 15, Palette.Secondary),
+ Ui.Text(visible ? L("共享屏幕时对方看得到") : L("屏幕共享里看不到"), 12, Palette.Secondary, wrap: false));
+ Detach(dueText);
+ dueText.FontSize = 12; dueText.Foreground = Palette.Secondary; dueText.VerticalAlignment = VerticalAlignment.Center;
+ FrameworkElement right = app.Settings.ShowInCapture ? Ui.Badge(L("对方可见")) : dueText;
+ var row = Ui.Spread(left, right);
+ row.Height = 40;
+ row.Margin = new Thickness(18, 0, 14, 2);
+ return row;
}
// MARK: The subtitle bar
@@ -461,27 +462,16 @@ sealed class NotesWindow : Window
header.VerticalAlignment = VerticalAlignment.Center;
grid.Children.Add(live);
grid.Children.Add(header);
- var handle = new Border { Width = 36, Height = 4, CornerRadius = new CornerRadius(2), Background = new SolidColorBrush(Color.FromArgb(0x38, 0xFF, 0xFF, 0xFF)), HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 0, 0, 6) };
- return Ui.Floating(new Border { Padding = new Thickness(16, 6, 10, 14), Child = new StackPanel { Children = { handle, grid } } }, new SolidColorBrush(Color.FromArgb(0xF0, 0x15, 0x17, 0x1C)), 14, dark: true);
+ return Ui.Floating(new Border { Padding = new Thickness(22, 14, 14, 16), Child = grid }, new SolidColorBrush(Color.FromArgb(0xF2, 0x1B, 0x1D, 0x22)), 16, dark: true);
}
+ /// The bar as on the Mac: who and the original on one small line, the translation big and bold.
FrameworkElement SubtitleLine()
{
var listen = app.Listen;
var session = listen.SessionId is { } id ? app.Store.Get(id) : null;
var line = session?.Lines.LastOrDefault();
- var left = new StackPanel { Width = 52, VerticalAlignment = VerticalAlignment.Center };
- if (listen.Listening && session is not null)
- {
- var dot = Ui.LiveDot(10);
- dot.HorizontalAlignment = HorizontalAlignment.Center;
- left.Children.Add(dot);
- Detach(clockText);
- clockText.FontSize = 11; clockText.Foreground = Palette.NightText;
- clockText.HorizontalAlignment = HorizontalAlignment.Center; clockText.Margin = new Thickness(0, 6, 0, 0);
- left.Children.Add(clockText);
- }
- var text = new StackPanel { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(8, 0, 12, 0) };
+ var text = new StackPanel { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 12, 0) };
// Asked to end: the one time the bar carries buttons, as the panel's card does.
if (listen.Listening && app.ConfirmingEnd)
{
@@ -491,10 +481,7 @@ sealed class NotesWindow : Window
var buttons = Ui.Row(8, Ui.Button(L("继续记录"), app.CancelStop, height: 32), Ui.Button(L("结束会议"), () => _ = app.StopListening(), Ui.Kind.Pale, Icons.Stop, 32, iconFill: true));
buttons.Margin = new Thickness(0, 8, 0, 0);
text.Children.Add(buttons);
- var bar = new DockPanel();
- DockPanel.SetDock(left, Dock.Left);
- bar.Children.Add(left); bar.Children.Add(text);
- return bar;
+ return text;
}
// The subtitle bar has no room for buttons: it says what will happen (the Mac's notice).
if (listen.Listening && app.Ending is not null)
@@ -509,14 +496,15 @@ sealed class NotesWindow : Window
text.Children.Add(Ui.Text(listen.Listening ? L("等有人说话") : L("点“开始听”,电脑里播放的声音会变成双语字幕和纪要"), 15, Palette.NightText));
else
{
- if (line.Dst is not null && line.Dst != line.Src) text.Children.Add(Ui.Text(line.Src, 14, Palette.NightText));
- text.Children.Add(Gap(Ui.Text(line.Dst ?? line.Src, app.Settings.SubtitleSize, Brushes.White, FontWeights.SemiBold), 4, top: true));
+ var number = app.Settings.SpeakerVoices && line.Speaker == "them" && SpeakerLabels.Numbers(session!.Lines).TryGetValue(line.Id, out var n) ? n : (int?)null;
+ var who = line.Speaker == "me" ? L("你") : number is { } k ? LF("说话人 %lld", k) : null;
+ var top = new TextBlock { FontFamily = Palette.Font, FontSize = 13, TextTrimming = TextTrimming.CharacterEllipsis, Foreground = Palette.NightText };
+ if (who is not null) top.Inlines.Add(new System.Windows.Documents.Run(who + " ") { Foreground = NightAccent });
+ if (line.Dst is not null && line.Dst != line.Src) top.Inlines.Add(new System.Windows.Documents.Run(line.Src));
+ if (top.Inlines.Count > 0) text.Children.Add(top);
+ text.Children.Add(Gap(Ui.Text(line.Dst ?? line.Src, app.Settings.SubtitleSize, Brushes.White, FontWeights.Bold), 4, top: true));
}
- var row = new DockPanel();
- DockPanel.SetDock(left, Dock.Left);
- row.Children.Add(left);
- row.Children.Add(text);
- return row;
+ return text;
}
// MARK: Bits
diff --git a/windows/src/Cicada/Onboarding.cs b/windows/src/Cicada/Onboarding.cs
index 9483918..3002ca1 100644
--- a/windows/src/Cicada/Onboarding.cs
+++ b/windows/src/Cicada/Onboarding.cs
@@ -8,19 +8,23 @@ using static Cicada.Strings;
namespace Cicada.App;
-/// First run, as a Windows setup window: a stepper, one task per step, Back / Continue at the
-/// bottom right. Windows needs no permission for system audio and listening needs the Ling key
-/// (recognition is Ming's), so: 接上 Ling → 系统声音 → 试一下.
+/// First run, as the Mac's setup window without Windows' title bar: the logo and a bar per step
+/// along the top, a big heading with one grey line, the task in white cards, Back / Continue at the
+/// bottom. Windows needs no permission for system audio and listening needs the Ling key
+/// (recognition is Ming's), so: 接 Ling → 听声音 → 看效果 → 同声传译, then where the tray icon lives.
sealed class Onboarding : Window
{
readonly Controller app;
readonly ContentControl stepper = new(), page = new(), footer = new();
int step;
+ const int Steps = 4;
SystemAudioTap? tap;
readonly DispatcherTimer meter = new() { Interval = TimeSpan.FromMilliseconds(80) };
- readonly double[] levels = new double[44];
+ readonly double[] levels = new double[9];
double level, peak;
bool autoStart = true, playing;
+ // 同声传译 is on while its step is showing (so 右 Ctrl can be tried); this is what it was before.
+ bool? speakBefore;
// Step 1: the key field and what we know about it
readonly PasswordBox keyBox = new() { FontSize = 14, MinHeight = 34, VerticalContentAlignment = VerticalAlignment.Center };
readonly TextBox keyText = new() { FontSize = 14, MinHeight = 34, VerticalContentAlignment = VerticalAlignment.Center, Visibility = Visibility.Collapsed };
@@ -31,16 +35,17 @@ sealed class Onboarding : Window
{
this.app = app;
Title = L("设置知了");
- Width = 760; Height = 640; ResizeMode = ResizeMode.NoResize;
+ Width = 860; Height = 640; ResizeMode = ResizeMode.CanMinimize;
Background = Palette.Page; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
var dock = new DockPanel();
DockPanel.SetDock(stepper, Dock.Top);
DockPanel.SetDock(footer, Dock.Bottom);
dock.Children.Add(stepper); dock.Children.Add(footer); dock.Children.Add(page);
- Content = dock;
+ Content = Ui.Frameless(this, dock, resizable: false, captionHeight: 24);
meter.Tick += (_, _) => { if (step == 1) Meter(); };
- Closed += (_, _) => StopTap();
+ app.Speak.Changed += SpeakChanged;
+ Closed += (_, _) => { StopTap(); app.Speak.Changed -= SpeakChanged; LeaveSpeak(keep: false); };
System.Windows.Automation.AutomationProperties.SetName(keyBox, L("Ling key"));
System.Windows.Automation.AutomationProperties.SetName(keyText, L("Ling key"));
keyBox.PasswordChanged += (_, _) => { if (keyText.Text != keyBox.Password) keyText.Text = keyBox.Password; };
@@ -49,10 +54,14 @@ sealed class Onboarding : Window
Render();
}
+ /// Dev: open on a given step (cicadactl show onboarding <n>).
+ public Onboarding At(int to) { Go(to); return this; }
+
void Go(int to)
{
StopTap();
- if (to > 2)
+ if (step == 3 && to != 3) LeaveSpeak(keep: to > 3 && Endpoints.Cable() is not null);
+ if (to > Steps)
{
AutoStart.Enabled = autoStart;
app.Settings.Onboarded = true; app.Settings.Save();
@@ -61,34 +70,44 @@ sealed class Onboarding : Window
return;
}
step = Math.Max(0, to);
+ if (step == 3 && speakBefore is null) { speakBefore = app.Settings.Speak; app.Settings.Speak = true; }
Render();
}
+ /// Leaving 同声传译: keep it on (继续, with the virtual mic in), or put back what it was.
+ void LeaveSpeak(bool keep)
+ {
+ if (speakBefore is not { } before) return;
+ app.Settings.Speak = keep || before;
+ app.Settings.Save();
+ speakBefore = null;
+ }
+
void Render()
{
stepper.Content = Stepper();
- page.Content = step switch { 0 => KeyStep(), 1 => AudioStep(), _ => SampleStep() };
+ page.Content = step switch { 0 => KeyStep(), 1 => AudioStep(), 2 => SampleStep(), 3 => SpeakStep(), _ => DoneStep() };
footer.Content = Footer();
}
- // The Mac's setup layout (Onboarding.swift): the logo and a bar per step along the top, a big
- // bold heading with one grey line, the task in one white card, Back and Continue at the bottom.
+ // The Mac's setup layout (Onboarding.swift): the logo and a bar per step along the top. The last
+ // page isn't a step: the logo alone.
FrameworkElement Stepper()
{
- var grid = new Grid { Margin = new Thickness(40, 28, 40, 0) };
+ var grid = new Grid { Margin = new Thickness(64, 36, 64, 0) };
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
- string[] names = [L("接上 Ling"), L("系统声音"), L("试一下")];
- for (int i = 0; i < names.Length; i++) grid.ColumnDefinitions.Add(new ColumnDefinition());
- var logo = AppIcon.Small(40);
- logo.Margin = new Thickness(0, 0, 18, 0);
+ var logo = AppIcon.Small(34);
+ logo.Margin = new Thickness(0, 0, 14, 0); logo.VerticalAlignment = VerticalAlignment.Top;
grid.Children.Add(logo);
+ if (step >= Steps) return grid;
+ string[] names = [L("接 Ling"), L("听声音"), L("看效果"), L("同声传译")];
+ for (int i = 0; i < names.Length; i++) grid.ColumnDefinitions.Add(new ColumnDefinition());
for (int i = 0; i < names.Length; i++)
{
- var reached = i <= step;
- var bar = new Border { Height = 4, CornerRadius = new CornerRadius(2), Background = reached ? Palette.Ink : Palette.Line };
- var name = Ui.Text(names[i], 13, i == step ? Palette.Ink : Palette.Secondary, i == step ? FontWeights.Bold : FontWeights.Normal, wrap: false);
+ var bar = new Border { Height = 4, CornerRadius = new CornerRadius(2), Background = i <= step ? Palette.Ink : Palette.Line };
+ var name = Ui.Text(names[i], 13, i == step ? Palette.Ink : Palette.Secondary, wrap: false);
name.Margin = new Thickness(0, 9, 0, 0);
- var col = new StackPanel { Margin = new Thickness(i == 0 ? 0 : 6, 6, 0, 0), Children = { bar, name } };
+ var col = new StackPanel { Margin = new Thickness(i == 0 ? 0 : 6, 8, 0, 0), Children = { bar, name } };
Grid.SetColumn(col, i + 1);
grid.Children.Add(col);
}
@@ -97,66 +116,96 @@ sealed class Onboarding : Window
FrameworkElement Page(string title, string text, params UIElement[] body)
{
- var s = new StackPanel { Margin = new Thickness(40, 36, 40, 0) };
- s.Children.Add(Ui.Text(title, 28, Palette.Ink, FontWeights.Bold));
- var p = Ui.Text(text, 15, Palette.Secondary);
- p.Margin = new Thickness(0, 10, 0, 0); p.LineHeight = 22;
+ var s = new StackPanel { Margin = new Thickness(64, 30, 64, 0) };
+ s.Children.Add(Ui.Text(title, 30, Palette.Ink, FontWeights.Bold));
+ var p = Ui.Text(text, 14, Palette.Secondary);
+ p.Margin = new Thickness(0, 8, 0, 0); p.LineHeight = 22;
s.Children.Add(p);
- foreach (var b in body) { if (b is FrameworkElement f) f.Margin = new Thickness(f.Margin.Left, f.Margin.Top + 24, f.Margin.Right, f.Margin.Bottom); s.Children.Add(b); }
+ foreach (var b in body) { if (b is FrameworkElement f) f.Margin = new Thickness(f.Margin.Left, f.Margin.Top + (s.Children.Count == 2 ? 24 : 16), f.Margin.Right, f.Margin.Bottom); s.Children.Add(b); }
return s;
}
- /// The Mac's white step card: 18-point corners and a hairline.
- static Border StepCard(UIElement child) => new()
+ /// The Mac's white step card: 18-point corners, no line on the grey ground.
+ static Border StepCard(UIElement child, Thickness? padding = null) => new()
{
- Background = Brushes.White, BorderBrush = Palette.Line, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(18),
- Padding = new Thickness(28, 24, 28, 24), Child = child,
+ Background = Brushes.White, CornerRadius = new CornerRadius(18),
+ Padding = padding ?? new Thickness(22, 20, 22, 20), Child = child,
};
- /// A numbered row in a step card: a grey disc with the number, a bold line, a grey line.
- static FrameworkElement Numbered(int n, string title, string? detail, UIElement? right = null, UIElement? below = null)
+ /// Two cards side by side, the first wider.
+ static Grid Columns(UIElement main, UIElement side, double sideWidth = 236)
+ {
+ var g = new Grid();
+ g.ColumnDefinitions.Add(new ColumnDefinition());
+ g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(16) });
+ g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(sideWidth) });
+ Grid.SetColumn(side, 2);
+ g.Children.Add(main); g.Children.Add(side);
+ return g;
+ }
+
+ /// The lead of a numbered row: a grey disc with the number, or a green-tinted tick once it's done.
+ static FrameworkElement Disc(int n, bool done = false)
+ {
+ var disc = new Grid { Width = 26, Height = 26, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 0, 14, 0) };
+ disc.Children.Add(new Ellipse { Fill = done ? new SolidColorBrush(Color.FromRgb(0xE3, 0xF1, 0xE8)) : Palette.Mica });
+ if (done) disc.Children.Add(Ui.Icon(Icons.Check, 14, Palette.Success, stroke: 1.8));
+ else { var num = Ui.Text($"{n}", 13, Palette.Ink, wrap: false); num.HorizontalAlignment = HorizontalAlignment.Center; num.VerticalAlignment = VerticalAlignment.Center; disc.Children.Add(num); }
+ return disc;
+ }
+
+ /// A numbered row in a step card: the disc, a line in ink, a grey line, and maybe a control.
+ static FrameworkElement Numbered(FrameworkElement lead, string title, string? detail, UIElement? right = null, UIElement? below = null)
{
- var disc = new Grid { Width = 32, Height = 32, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 0, 16, 0) };
- disc.Children.Add(new Ellipse { Fill = Palette.Mica });
- var num = Ui.Text($"{n}", 15, Palette.Ink, FontWeights.Bold, wrap: false); num.HorizontalAlignment = HorizontalAlignment.Center; num.VerticalAlignment = VerticalAlignment.Center;
- disc.Children.Add(num);
var text = new StackPanel { VerticalAlignment = VerticalAlignment.Center };
- text.Children.Add(Ui.Text(title, 17, Palette.Ink, FontWeights.Bold));
+ text.Children.Add(Ui.Text(title, 16, Palette.Ink));
if (detail is not null) { var d = Ui.Text(detail, 13, Palette.Secondary); d.Margin = new Thickness(0, 3, 0, 0); text.Children.Add(d); }
- if (below is FrameworkElement b) { b.Margin = new Thickness(0, 12, 0, 0); text.Children.Add(b); }
+ if (below is FrameworkElement b) { b.Margin = new Thickness(0, 14, 0, 0); text.Children.Add(b); }
var dock = new DockPanel();
- DockPanel.SetDock(disc, Dock.Left);
- dock.Children.Add(disc);
- if (right is FrameworkElement r) { DockPanel.SetDock(r, Dock.Right); r.VerticalAlignment = VerticalAlignment.Center; r.Margin = new Thickness(16, 0, 0, 0); dock.Children.Add(r); }
+ DockPanel.SetDock(lead, Dock.Left);
+ dock.Children.Add(lead);
+ if (right is FrameworkElement r) { DockPanel.SetDock(r, Dock.Right); r.VerticalAlignment = below is null ? VerticalAlignment.Center : VerticalAlignment.Top; r.HorizontalAlignment = HorizontalAlignment.Right; r.Margin = new Thickness(16, 0, 0, 0); dock.Children.Add(r); }
dock.Children.Add(text);
return dock;
}
- static FrameworkElement Divider() => new Border { Height = 1, Background = Palette.Line, Margin = new Thickness(0, 20, 0, 20) };
+ static FrameworkElement Divider(double gap = 20) => new Border { Height = 1, Background = Palette.Line, Margin = new Thickness(0, gap, 0, gap) };
+
+ static FrameworkElement Tick(string text) => Ui.Row(6, Ui.Icon(Icons.Check, 14, Palette.Success, stroke: 1.8), Ui.Text(text, 14, Palette.Success, wrap: false));
FrameworkElement Footer()
{
- var back = Ui.Button(L("上一步"), () => Go(step - 1), Ui.Kind.Subtle, height: 48);
- back.MinWidth = 0; back.HorizontalAlignment = HorizontalAlignment.Left;
- back.Visibility = step > 0 ? Visibility.Visible : Visibility.Hidden;
+ var back = Ui.Button(L("上一步"), () => Go(step - 1), Ui.Kind.Subtle, height: 44);
+ back.MinWidth = 0; back.HorizontalAlignment = HorizontalAlignment.Left; back.Padding = new Thickness(0);
+ ((TextBlock)((StackPanel)back.Content).Children[0]).Foreground = Palette.Secondary;
+ UIElement left = back;
+ if (step == 0)
+ left = Ui.Row(8, Ui.Icon(Icons.Lock, 14, Palette.Secondary), Ui.Text(L("key 加密存在这台电脑上,只发给 Ling"), 13, Palette.Secondary, wrap: false));
var next = step switch
{
- 0 => Ui.Button(L("继续"), () => _ = SaveKey(), Ui.Kind.Primary, height: 48),
- 1 => Ui.Button(L("继续"), () => Go(2), peak >= 0.01 ? Ui.Kind.Primary : Ui.Kind.Standard, height: 48),
- _ => Ui.Button(L("完成"), () => Go(3), Ui.Kind.Primary, height: 48),
+ 0 => Ui.Button(L("继续"), () => _ = SaveKey(), Ui.Kind.Primary, Icons.Arrow, height: 44, iconAfter: true),
+ 1 => Ui.Button(L("继续"), () => Go(2), peak >= 0.01 ? Ui.Kind.Primary : Ui.Kind.Standard, Icons.Arrow, height: 44, iconAfter: true),
+ < Steps => Ui.Button(L("继续"), () => Go(step + 1), Ui.Kind.Primary, Icons.Arrow, height: 44, iconAfter: true),
+ _ => Ui.Button(L("开始用"), () => Go(Steps + 1), Ui.Kind.Primary, height: 44),
};
- next.MinWidth = 150; next.HorizontalAlignment = HorizontalAlignment.Right;
+ next.MinWidth = 108; next.HorizontalAlignment = HorizontalAlignment.Right;
next.IsEnabled = !checking;
var right = new StackPanel { Orientation = Orientation.Horizontal };
if (step == 1)
{
- var hint = Ui.Text(L("没有声音?先确认电脑没静音"), 13, Palette.Secondary, wrap: false);
+ var hint = Ui.Text(L("音量条没动?放段视频或音乐试试"), 13, Palette.Secondary, wrap: false);
hint.VerticalAlignment = VerticalAlignment.Center; hint.Margin = new Thickness(0, 0, 16, 0);
right.Children.Add(hint);
}
+ if (step == 3)
+ {
+ var later = Ui.Button(L("以后再说"), () => { LeaveSpeak(keep: false); speakBefore = null; step = 4; Render(); }, height: 44);
+ later.Margin = new Thickness(0, 0, 12, 0); later.MinWidth = 100; later.Background = Palette.Selected;
+ right.Children.Add(later);
+ }
right.Children.Add(next);
- var row = Ui.Spread(back, right);
- row.Margin = new Thickness(28, 16, 40, 28);
+ var row = Ui.Spread(left, right);
+ row.Margin = new Thickness(64, 16, 64, 36);
return row;
}
@@ -164,8 +213,8 @@ sealed class Onboarding : Window
FrameworkElement KeyStep()
{
- var open = Ui.Button(L("打开 Ling 开放平台 ↗"), () => Process.Start(new ProcessStartInfo("https://chat.ant-ling.com/platform/api") { UseShellExecute = true }));
- open.HorizontalAlignment = HorizontalAlignment.Right;
+ var open = Ui.Button(L("打开"), () => Process.Start(new ProcessStartInfo("https://chat.ant-ling.com/platform/api") { UseShellExecute = true }), icon: Icons.OpenExternal, height: 36, iconAfter: true);
+ open.MinWidth = 0;
var reveal = Ui.IconButton(Icons.Eye, L("显示 key"), () =>
{
var show = keyText.Visibility != Visibility.Visible;
@@ -189,35 +238,47 @@ sealed class Onboarding : Window
{
try { if (Clipboard.ContainsText()) keyText.Text = Clipboard.GetText().Trim(); } catch { }
_ = SaveKey();
- }, Ui.Kind.Primary, Icons.Copy, height: 40);
+ }, Ui.Kind.Primary, height: 40);
var row = new DockPanel();
DockPanel.SetDock(paste, Dock.Right);
- paste.Margin = new Thickness(10, 0, 0, 0);
+ paste.Margin = new Thickness(8, 0, 0, 0);
row.Children.Add(paste); row.Children.Add(field);
- if (app.Ling.HasKey && keyBox.Password.Length == 0) Status(true, AIKey.Masked(app.Key.Read() ?? "") + " · " + L("可以用"));
- var privacy = Ui.Row(8, Ui.Icon(Icons.Shield, 15, Palette.Secondary), Ui.Text(L("只加密存在这台电脑上,只发给 Ling"), 13, Palette.Secondary));
- keyStatus.Margin = new Thickness(0, 8, 0, 0);
- var second = new StackPanel { Children = { row, keyStatus, privacy } };
- privacy.Margin = new Thickness(0, 10, 0, 0);
+ if (app.Ling.HasKey && keyBox.Password.Length == 0 && keyStatus.Content is null) Status(true, AIKey.Masked(app.Key.Read() ?? "") + " · " + L("已连接,可以用了"));
+ keyStatus.Margin = new Thickness(0, 12, 0, 0);
+ var second = new StackPanel { Children = { row, keyStatus } };
var card = StepCard(new StackPanel
{
Children =
{
- Numbered(1, L("在 Ling 开放平台创建 key"), L("注册或登录后点“创建令牌”"), open),
+ Numbered(Disc(1), L("在 Ling 开放平台创建 key"), L("国内直接注册,不用代理;登录后点“创建令牌”"), open),
Divider(),
- Numbered(2, L("复制 sk- 开头的 key,回来粘贴"), null, below: second),
+ Numbered(Disc(2), L("复制 sk- 开头的 key,回来粘贴"), null, below: second),
},
});
- return Page(L("接上 Ling,用上完整的知了"), L("识别、翻译和纪要都靠它,约 1 分钟。"), card);
+ FrameworkElement Benefit(string title, string detail) => new StackPanel { Margin = new Thickness(0, 14, 0, 0), Children = { Ui.Text(title, 14, Palette.Ink), Gap(Ui.Text(detail, 12, Palette.Secondary), 2) } };
+ var side = StepCard(new StackPanel
+ {
+ Children =
+ {
+ Ui.Text(L("Ling 每月赠送 ¥10 额度"), 16, Palette.Ink, FontWeights.Bold),
+ Gap(Ui.Text(L("约够 10–50 小时会议"), 13, Palette.Secondary), 4),
+ new Border { Height = 1, Background = Palette.Line, Margin = new Thickness(0, 14, 0, 0) },
+ Benefit(L("实时纪要"), L("会中每 45 秒更新")),
+ Benefit(L("更准的翻译"), L("人名、术语前后一致")),
+ Benefit(L("自然人声"), L("同传约 2 秒出声")),
+ },
+ }, new Thickness(20, 20, 20, 20));
+ return Page(L("接上 Ling"), L("识别、翻译和纪要都靠它,约 1 分钟。"), Columns(card, side));
}
+ static FrameworkElement Gap(FrameworkElement e, double top) { e.Margin = new Thickness(0, top, 0, 0); return e; }
+
static void Detach(FrameworkElement e) { if (e.Parent is Panel p) p.Children.Remove(e); else if (e.Parent is ContentControl c) c.Content = null; else if (e.Parent is Decorator d) d.Child = null; }
void Status(bool? ok, string text)
{
var color = ok == true ? Palette.Success : ok == false ? Palette.Danger : Palette.Secondary;
- var icon = ok == true ? (FrameworkElement)new Grid { Width = 16, Height = 16, Children = { new Ellipse { Fill = Palette.Success }, Ui.Icon(Icons.Check, 16, Brushes.White, stroke: 2) } } : new Border();
- keyStatus.Content = Ui.Row(6, icon, Ui.Text(text, 13, color));
+ keyStatus.Content = ok == true ? Tick(text) : Ui.Text(text, 13, color);
}
async Task SaveKey()
@@ -232,7 +293,7 @@ sealed class Onboarding : Window
app.Ling.KeyChanged();
var (state, _) = await app.Ling.Check();
checking = false; footer.Content = Footer();
- if (state == KeyState.Ok) { Status(true, L("可以用")); await Task.Delay(400); Go(1); return; }
+ if (state == KeyState.Ok) { Status(true, L("已连接,可以用了")); await Task.Delay(600); Go(1); return; }
// A key Ling turned down isn't kept: the one that worked before, if any, comes back.
if (state == KeyState.Invalid)
{
@@ -264,41 +325,42 @@ sealed class Onboarding : Window
meter.Start();
}
Detach(meterHost); Detach(heardHost);
+ heardHost.Tag = null;
Meter();
+ var tile = new Border { Width = 44, Height = 44, CornerRadius = new CornerRadius(12), Background = Palette.Mica, Margin = new Thickness(0, 0, 16, 0), Child = Ui.Icon(Icons.Speaker, 20, Palette.Ink) };
+ var status = Ui.Row(18, meterHost, heardHost);
var device = AudioDevice.DefaultName();
+ var from = new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(8), Padding = new Thickness(12, 6, 12, 6), Child = Ui.Text(device ?? L("默认扬声器"), 13, Palette.Ink, wrap: false), MaxWidth = 340 };
var card = StepCard(new StackPanel
{
Children =
{
- Ui.Row(14, Ui.Icon(Icons.Speaker, 22, Palette.Body), meterHost),
- new Border { Height = 14 }, heardHost,
- Divider(),
- Ui.Text(device is null ? L("换成耳机或蓝牙音箱也能接着听。") : $"{LF("正在听:%@", device)} · {L("换成耳机或蓝牙音箱也能接着听。")}", 13, Palette.Secondary),
+ Numbered(tile, L("听电脑里的声音"), L("只听声音,不录屏幕画面,也不占麦克风"), status),
+ Divider(16),
+ Ui.Spread(Ui.Text(L("从哪里听"), 14, Palette.Body, wrap: false), from),
},
});
- return Page(L("系统声音"), L("知了听的是电脑播放出来的声音,不用麦克风,也不用授权。放一段视频或音乐试试。"), card);
+ var note = Ui.Row(8, Ui.Icon(Icons.EyeOff, 15, Palette.Secondary), Ui.Text(L("纪要窗不会出现在截图和屏幕共享里"), 13, Palette.Secondary, wrap: false));
+ return Page(L("让知了听到电脑里的声音"), L("字幕和纪要都从这里来。Windows 上不用授权,放点声音就行。"), card, note);
}
- /// 32 bars of the last few seconds of loudness, newest on the right.
+ /// A few bars of the last moment's loudness, newest on the right, in the accent once there's sound.
void Meter()
{
// A rolling history of the loudness, eased so a word reads as a rise and fall, not one spike.
Array.Copy(levels, 1, levels, 0, levels.Length - 1);
levels[^1] = Math.Max(Loudness(level), levels[^2] * 0.7);
level = 0;
- var bars = new StackPanel { Orientation = Orientation.Horizontal, Height = 40 };
+ var bars = new StackPanel { Orientation = Orientation.Horizontal, Height = 22, VerticalAlignment = VerticalAlignment.Center };
foreach (var v in levels)
- bars.Children.Add(new Rectangle { Width = 3, Height = 4 + v * 36, RadiusX = 1.5, RadiusY = 1.5, Margin = new Thickness(0, 0, 9, 0), VerticalAlignment = VerticalAlignment.Center, Fill = v > 0.08 ? Palette.Live : Palette.Line });
+ bars.Children.Add(new Rectangle { Width = 3, Height = 3 + v * 19, RadiusX = 1, RadiusY = 1, Margin = new Thickness(0, 0, 3, 0), VerticalAlignment = VerticalAlignment.Bottom, Fill = v > 0.08 ? Palette.Live : Palette.Toggle });
System.Windows.Automation.AutomationProperties.SetName(bars, L("系统声音"));
meterHost.Content = bars;
var heard = peak >= 0.01;
- var was = heardHost.Tag as bool?;
- if (was != heard)
+ if (heardHost.Tag as bool? != heard)
{
heardHost.Tag = heard;
- heardHost.Content = heard
- ? Ui.Row(8, new Grid { Width = 18, Height = 18, Children = { new Ellipse { Fill = Palette.Success }, Ui.Icon(Icons.Check, 18, Brushes.White, stroke: 2) } }, Ui.Text(L("听到了"), 14, Palette.Success, FontWeights.SemiBold, wrap: false))
- : Ui.Text(L("还没听到声音"), 14, Palette.Secondary, wrap: false);
+ heardHost.Content = heard ? Ui.Row(6, Ui.Icon(Icons.Check, 14, Palette.Ink, stroke: 1.8), Ui.Text(L("已收到声音"), 14, Palette.Ink, wrap: false)) : Ui.Text(L("还没听到声音"), 14, Palette.Secondary, wrap: false);
footer.Content = Footer();
}
}
@@ -310,20 +372,19 @@ sealed class Onboarding : Window
FrameworkElement SampleStep()
{
- var play = Ui.Button(playing ? L("正在播放…") : L("播放示例"), () => _ = PlaySample(), Ui.Kind.Accent, Icons.Play, 48, iconFill: true);
+ var play = Ui.Button(playing ? L("正在播放…") : L("播放示例"), () => _ = PlaySample(), Ui.Kind.Accent, Icons.Play, 40, iconFill: true);
play.IsEnabled = !playing;
- play.MinWidth = 160;
- var startup = Ui.Switch(autoStart, v => autoStart = v, L("开机时启动知了"));
+ play.MinWidth = 132;
var card = StepCard(new StackPanel
{
Children =
{
- Numbered(1, L("播放示例"), L("一段 9 秒的英文会议"), play),
+ Numbered(Disc(1), L("播放示例"), L("一段 9 秒的英文会议"), play),
Divider(),
- Numbered(2, L("开机时启动知了"), LF("开会时点任务栏里的知了图标,或按 %@ 开始。", Hotkey.Label), startup),
+ Numbered(Disc(2), L("看右边的纪要窗"), L("字幕和纪要一句句出来;点它不会抢走你正在用的窗口")),
},
});
- return Page(L("试一下"), L("看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。"), card);
+ return Page(L("看看效果"), L("看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。"), card);
}
async Task PlaySample()
@@ -337,6 +398,157 @@ sealed class Onboarding : Window
finally { playing = false; if (IsLoaded) Render(); }
}
+ // MARK: 4 · Speak into the meeting
+
+ string? cableProgress;
+
+ FrameworkElement SpeakStep()
+ {
+ var cable = Endpoints.Cable() is not null;
+ FrameworkElement cableControl = cable ? Ui.Text(L("已装好"), 14, Palette.Success, wrap: false)
+ : cableProgress is { } busy ? Ui.Text(busy, 13, Palette.Secondary, wrap: false)
+ : Ui.Button(L("安装"), () => _ = InstallCable(), Ui.Kind.Primary, height: 36);
+ var held = app.Speak.State == SpeakEngine.Phase.Recording;
+ var key = Ui.Keycap(PushToTalk.Label, big: true);
+ if (held) { key.Background = Palette.AccentPale; key.BorderBrush = Palette.Live; }
+ FrameworkElement tried = app.Speak.State switch
+ {
+ SpeakEngine.Phase.Recording => Ui.Text(L("正在听你说 · 松开发送"), 13, Palette.AccentText),
+ SpeakEngine.Phase.Translating => Ui.Text(L("正在翻译…"), 13, Palette.Secondary),
+ SpeakEngine.Phase.Speaking => Ui.Text(L("正在说给对方听…"), 13, Palette.Secondary),
+ SpeakEngine.Phase.Failed => Ui.Text(app.Speak.Problem ?? L("没翻译成功,没有发出去"), 13, Palette.Danger),
+ _ when app.Speak.Heard is { } h => Tick(L("对方已听到") + ":" + h),
+ _ => new Border(),
+ };
+ var card = StepCard(new StackPanel
+ {
+ Children =
+ {
+ Numbered(Disc(1, cable), L("装一个虚拟麦克风"), L("VB-Cable,免费,Windows 会问一次是否允许"), cableControl),
+ Divider(),
+ Numbered(Disc(2), L("会议软件里,麦克风选 CABLE Output"), L("Teams、Zoom、腾讯会议都在“音频设置”里")),
+ Divider(),
+ Numbered(Disc(3), L("按住说一句试试"), L("松开后约 2 秒,对方就会听到译文"), key, tried is Border ? null : tried),
+ },
+ });
+ return Page(L("要让对方听懂你说的话吗?"), LF("按住%@说话,对方在会议里听到翻译后的声音。不需要可以跳过。", PushToTalk.Label), card);
+ }
+
+ void SpeakChanged() => Dispatcher.BeginInvoke(() => { if (step == 3 && IsLoaded) page.Content = SpeakStep(); });
+
+ async Task InstallCable()
+ {
+ cableProgress = L("正在下载…"); Render();
+ var result = await CableInstaller.Install(p => Dispatcher.BeginInvoke(() => { cableProgress = p; Render(); }));
+ cableProgress = null;
+ Render();
+ if (result != CableInstaller.Result.Installed)
+ Dialogs.Tell(this, L("虚拟麦克风没装上"), result switch
+ {
+ CableInstaller.Result.DownloadFailed => L("下载失败,检查网络后再试。"),
+ CableInstaller.Result.BadPackage => L("下载到的安装包和预期的不一样,为了安全没有安装。"),
+ CableInstaller.Result.Declined => L("需要你在 Windows 的提示里点“是”才能安装。"),
+ _ => L("安装没有完成,可以重启电脑后再试。"),
+ });
+ }
+
+ // MARK: Done · where the icon lives
+
+ /// Text that wraps on the left of a button that keeps its full width (English runs wider).
+ static FrameworkElement Beside(FrameworkElement text, FrameworkElement button)
+ {
+ var d = new DockPanel();
+ DockPanel.SetDock(button, Dock.Right);
+ button.Margin = new Thickness(12, 0, 0, 0); button.VerticalAlignment = VerticalAlignment.Center;
+ text.VerticalAlignment = VerticalAlignment.Center;
+ d.Children.Add(button); d.Children.Add(text);
+ return d;
+ }
+
+
+ FrameworkElement DoneStep()
+ {
+ var settings = Ui.Button(L("打开任务栏设置"), () => { try { Process.Start(new ProcessStartInfo("ms-settings:taskbar") { UseShellExecute = true }); } catch { } }, height: 36);
+ settings.MinWidth = 0;
+ var pin = StepCard(new StackPanel
+ {
+ Children =
+ {
+ TrayPicture(),
+ Gap(Beside(Ui.Text(L("拖不动?在任务栏设置里打开“知了”"), 13, Palette.Body), settings), 16),
+ },
+ });
+ FrameworkElement Key(string what, string keys) => Gap(Ui.Spread(Ui.Text(what, 14, Palette.Ink, wrap: false), Ui.Keycap(keys)), 14);
+ // An ink box like the design's, not the theme's blue one; still a CheckBox for keys and readers.
+ var box = new Border { Width = 18, Height = 18, CornerRadius = new CornerRadius(4) };
+ void Paint()
+ {
+ box.Background = autoStart ? Palette.Ink : Palette.Surface;
+ box.BorderBrush = autoStart ? Palette.Ink : Palette.Secondary;
+ box.BorderThickness = new Thickness(autoStart ? 0 : 1.5);
+ box.Child = autoStart ? Ui.Icon(Icons.Check, 14, Brushes.White, stroke: 2.2) : null;
+ }
+ Paint();
+ var face = new FrameworkElementFactory(typeof(ContentPresenter));
+ var startup = new CheckBox
+ {
+ IsChecked = autoStart, Content = Ui.Row(10, box, Ui.Text(L("开机时启动知了"), 14, Palette.Ink, wrap: false)),
+ Template = new ControlTemplate(typeof(CheckBox)) { VisualTree = face }, Cursor = System.Windows.Input.Cursors.Hand,
+ HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0, 28, 0, 0),
+ };
+ System.Windows.Automation.AutomationProperties.SetName(startup, L("开机时启动知了"));
+ startup.Click += (_, _) => { autoStart = startup.IsChecked == true; Paint(); };
+ var keys = StepCard(new StackPanel
+ {
+ Children =
+ {
+ Ui.Text(L("在哪儿都能用"), 16, Palette.Ink, FontWeights.Bold),
+ Key(L("开始 / 结束听"), Hotkey.Label.Replace('+', ' ')),
+ Key(L("按住说话"), PushToTalk.Label),
+ startup,
+ },
+ });
+ return Page(L("好了,知了住在任务栏右下角"), L("Windows 会先把新图标收进 ^ 里。拖出来放在时钟旁边,开会时一眼就能看到。"), Columns(pin, keys, 260));
+ }
+
+ /// The corner of the taskbar: the ^ overflow with 知了 in it, and a dashed arrow to beside the clock.
+ static FrameworkElement TrayPicture()
+ {
+ var c = new Canvas { Height = 150, ClipToBounds = true };
+ var ground = new Border { Width = 412, Height = 150, CornerRadius = new CornerRadius(12), Background = new SolidColorBrush(Color.FromRgb(0xE1, 0xE4, 0xEA)) };
+ c.Children.Add(ground);
+ var bar = new Border { Width = 412, Height = 40, CornerRadius = new CornerRadius(0, 0, 12, 12), Background = new SolidColorBrush(Color.FromRgb(0xEE, 0xF0, 0xF3)), BorderBrush = new SolidColorBrush(Color.FromRgb(0xD3, 0xD7, 0xDE)), BorderThickness = new Thickness(0, 1, 0, 0) };
+ Canvas.SetTop(bar, 110); c.Children.Add(bar);
+ FrameworkElement Slot(bool ours, bool ring) => new Border
+ {
+ Width = 32, Height = 32, CornerRadius = new CornerRadius(7), Background = Brushes.White,
+ BorderBrush = ring ? Palette.Live : Brushes.Transparent, BorderThickness = new Thickness(ring ? 1.5 : 0),
+ Child = ours ? AppIcon.Small(22) : new Border { Width = 14, Height = 14, CornerRadius = new CornerRadius(3), Background = new SolidColorBrush(Color.FromRgb(0xAE, 0xB3, 0xBF)) },
+ };
+ var overflow = new Border
+ {
+ CornerRadius = new CornerRadius(12), Background = Brushes.White, Padding = new Thickness(10, 8, 10, 8),
+ Child = new StackPanel { Orientation = Orientation.Horizontal, Children = { Plain(), Gap2(Slot(true, true)), Gap2(Plain()) } },
+ };
+ static FrameworkElement Plain() => new Border { Width = 32, Height = 32, Child = new Border { Width = 14, Height = 14, CornerRadius = new CornerRadius(3), Background = new SolidColorBrush(Color.FromRgb(0xAE, 0xB3, 0xBF)) } };
+ static FrameworkElement Gap2(FrameworkElement e) { e.Margin = new Thickness(8, 0, 0, 0); return e; }
+ Canvas.SetLeft(overflow, 176); Canvas.SetTop(overflow, 48); c.Children.Add(overflow);
+ var chevron = new Border { Width = 28, Height = 28, CornerRadius = new CornerRadius(6), Background = Brushes.White, Child = Ui.Icon("M6,12 L10,8 L14,12", 12, Palette.Body, stroke: 1.6) };
+ Canvas.SetLeft(chevron, 292); Canvas.SetTop(chevron, 116); c.Children.Add(chevron);
+ var mine = Slot(true, true);
+ Canvas.SetLeft(mine, 326); Canvas.SetTop(mine, 114); c.Children.Add(mine);
+ var clock = Ui.Text("14:30", 13, Palette.Ink, wrap: false);
+ Canvas.SetLeft(clock, 368); Canvas.SetTop(clock, 121); c.Children.Add(clock);
+ var arrow = new System.Windows.Shapes.Path
+ {
+ Data = Geometry.Parse("M272,72 C312,64 340,70 352,98 M345,92 L352,100 L358,91"), Stroke = Palette.Live, StrokeThickness = 1.6,
+ StrokeDashArray = [3, 2.5], StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round,
+ };
+ c.Children.Add(arrow);
+ var holder = new Border { CornerRadius = new CornerRadius(12), ClipToBounds = true, Child = new Viewbox { Stretch = Stretch.Uniform, StretchDirection = StretchDirection.DownOnly, Child = new Grid { Width = 412, Height = 150, Children = { c } } } };
+ return holder;
+ }
+
void StopTap()
{
meter.Stop();
diff --git a/windows/src/Cicada/SettingsWindow.cs b/windows/src/Cicada/SettingsWindow.cs
index 1840a41..2b4c91b 100644
--- a/windows/src/Cicada/SettingsWindow.cs
+++ b/windows/src/Cicada/SettingsWindow.cs
@@ -6,13 +6,14 @@ using static Cicada.Strings;
namespace Cicada.App;
-/// 设置, laid out as Windows 11 Settings: categories on the left, one card per setting with its
-/// control on the right, switches for on/off.
+/// 设置, as the Mac's settings window with no title bar: the categories as plain words on the left,
+/// the chosen one on a white pill, and its page on the right under a big title, the settings in
+/// white cards on the grey ground with each control at the right.
sealed class SettingsWindow : Window
{
readonly Controller app;
- readonly ScrollViewer scroll = new() { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(16, 0, 32, 32) };
- readonly StackPanel nav = new() { Margin = new Thickness(12, 8, 12, 12) };
+ readonly ScrollViewer scroll = new() { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(40, 44, 40, 40) };
+ readonly StackPanel nav = new() { Margin = new Thickness(12, 52, 12, 12) };
readonly Dictionary<string, FrameworkElement> sections = [];
readonly PasswordBox keyBox = new();
bool editingKey;
@@ -22,16 +23,16 @@ sealed class SettingsWindow : Window
{
this.app = app;
Title = L("设置") + " · " + L("知了");
- Width = 1000; Height = Math.Min(760, SystemParameters.WorkArea.Height - 24); MinWidth = 760; MinHeight = 480;
+ Width = 1000; Height = Math.Min(780, SystemParameters.WorkArea.Height - 24); MinWidth = 760; MinHeight = 480;
Background = Palette.Page; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
System.Windows.Automation.AutomationProperties.SetName(keyBox, L("Ling key"));
var grid = new Grid();
- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(240) });
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200) });
grid.ColumnDefinitions.Add(new ColumnDefinition());
Grid.SetColumn(scroll, 1);
grid.Children.Add(nav); grid.Children.Add(scroll);
- Content = grid;
+ Content = Ui.Frameless(this, grid);
app.Ling.Changed += OnLingChanged;
Closed += (_, _) => app.Ling.Changed -= OnLingChanged;
Render();
@@ -43,10 +44,7 @@ sealed class SettingsWindow : Window
{
var offset = scroll.VerticalOffset;
sections.Clear();
- var page = new StackPanel { MaxWidth = 860, HorizontalAlignment = HorizontalAlignment.Stretch };
- var title = Ui.Text(L("设置"), 28, Palette.Ink, FontWeights.Bold);
- title.Margin = new Thickness(0, 4, 0, 8);
- page.Children.Add(title);
+ var page = new StackPanel { MaxWidth = 640, HorizontalAlignment = HorizontalAlignment.Left };
Section(page, "ling", L("Ling"), KeyCard(), Group(Card(Icons.Notes, L("纪要和翻译用的模型"), L("3.1 更准;3.0 更快、更省。语音识别固定用 Ming。"),
Ui.Choice([("Ling-3.1-flash", "Ling-3.1-flash"), ("Ling-3.0-flash", "Ling-3.0-flash")], app.Settings.Model, v => { app.Settings.Model = v; app.Ling.Model = v; Save(); }))));
Section(page, "lang", L("语言"), Group(
@@ -60,7 +58,7 @@ sealed class SettingsWindow : Window
Card(Icons.Subtitles, L("听的时候显示"), null, Ui.Segmented([("notes", L("纪要")), ("subtitles", L("字幕条"))], app.Settings.View, app.SetView)),
Card(null, L("字幕文字大小"), null, size),
Card(Icons.Keyboard, L("开始或结束"), app.HotkeyRegistered ? L("在任何程序里都能按") : L("这个快捷键被别的程序占用了"), Keys(Hotkey.Label))));
- Section(page, "speak", L("同声传译"), SpeakCards());
+ Section(page, "speak", L("同声传译"), SpeakCards().ToArray());
Section(page, "end", L("结束会议"), EndCards());
Section(page, "privacy", L("隐私与启动"), Group(
Card(Icons.Eye, L("共享屏幕时让对方看到"), L("关着时,截图和屏幕共享里看不到纪要和字幕"), Ui.Switch(app.Settings.ShowInCapture, app.SetShowInCapture, L("共享屏幕时让对方看到"))),
@@ -70,10 +68,13 @@ sealed class SettingsWindow : Window
var version = typeof(SettingsWindow).Assembly.GetName().Version?.ToString(3) ?? "";
Section(page, "about", L("关于"), Group(Card(null, LF("知了 %@", version), L("说话人识别用 WeSpeaker 的声纹模型(CC BY 4.0)"), Ui.LinkText(L("打开日志"), () => OpenFolder(Path.GetDirectoryName(Paths.Log)!)), AppIcon.Small(24))));
scroll.Content = page;
- scroll.ScrollToVerticalOffset(offset);
+ scroll.ScrollToVerticalOffset(shownPage == current ? offset : 0);
+ shownPage = current;
Nav();
}
+ string? shownPage;
+
void Nav()
{
nav.Children.Clear();
@@ -87,15 +88,11 @@ sealed class SettingsWindow : Window
var on = id == current;
var content = new Grid();
- content.Children.Add(Ui.Row(12, Ui.Icon(icon, 18, Palette.Ink), Ui.Text(label, 14, Palette.Ink, on ? FontWeights.SemiBold : FontWeights.Normal, wrap: false)));
- var b = new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Content = content, Height = 40, Padding = new Thickness(12, 0, 12, 0), HorizontalContentAlignment = HorizontalAlignment.Left, Background = on ? Palette.Line : Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = System.Windows.Input.Cursors.Hand, Margin = new Thickness(0, 0, 0, 2) };
+ _ = icon;
+ content.Children.Add(Ui.Text(label, 14, Palette.Ink, on ? FontWeights.Bold : FontWeights.Normal, wrap: false));
+ var b = new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Content = content, Height = 38, Padding = new Thickness(12, 0, 12, 0), HorizontalContentAlignment = HorizontalAlignment.Left, Background = on ? Palette.Surface : Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = System.Windows.Input.Cursors.Hand, Margin = new Thickness(0, 0, 0, 2) };
b.Template = NavTemplate();
- b.Click += (_, _) =>
- {
- current = id; Nav();
- if (sections.TryGetValue(id, out var target))
- scroll.ScrollToVerticalOffset(target.TransformToAncestor((Visual)scroll.Content).Transform(new Point(0, 0)).Y - 8);
- };
+ b.Click += (_, _) => { current = id; Render(); };
System.Windows.Automation.AutomationProperties.SetName(b, label);
nav.Children.Add(b);
}
@@ -115,37 +112,43 @@ sealed class SettingsWindow : Window
var hover = new MultiTrigger();
hover.Conditions.Add(new Condition(UIElement.IsMouseOverProperty, true));
hover.Conditions.Add(new Condition(Control.BackgroundProperty, Brushes.Transparent));
- hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Mica, "bg"));
+ hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Selected, "bg"));
t.Triggers.Add(hover);
return t;
}
+ /// One category's page: only the chosen one is shown, under its name in big type (and, for
+ /// 同声传译, its on/off switch beside it).
void Section(StackPanel page, string id, string title, params FrameworkElement[] groups)
{
- var h = Ui.Text(title, 13, Palette.Secondary, FontWeights.Bold);
- h.Margin = new Thickness(0, 20, 0, 8);
+ if (id != current) return;
+ FrameworkElement h = Ui.Text(title, 28, Palette.Ink, FontWeights.Bold);
+ if (id == "speak") h = Ui.Spread(h, Ui.Switch(app.Settings.Speak, v => { app.Settings.Speak = v; Save(); }, L("同声传译")));
+ h.Margin = new Thickness(0, 0, 0, 20);
sections[id] = h;
page.Children.Add(h);
- foreach (var g in groups) { g.Margin = new Thickness(0, 0, 0, 6); page.Children.Add(g); }
+ foreach (var g in groups) { g.Margin = new Thickness(0, 0, 0, 12); page.Children.Add(g); }
}
- /// Cards that belong together share one border, with hairlines between them.
+ /// A grey label over a group, as the Mac's settings sections.
+ static FrameworkElement Label(string text) { var t = Ui.Text(text, 13, Palette.Secondary); t.Margin = new Thickness(6, 8, 0, 0); return t; }
+
+ /// Cards that belong together on one white card, with hairlines between them.
static FrameworkElement Group(params FrameworkElement[] cards)
{
var s = new StackPanel();
for (int i = 0; i < cards.Length; i++)
- s.Children.Add(new Border { BorderBrush = Palette.StrokeSoft, BorderThickness = new Thickness(0, i == 0 ? 0 : 1, 0, 0), Child = cards[i] });
- return new Border { Background = Palette.Surface, BorderBrush = Palette.Line, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(16), Child = s, Padding = new Thickness(4, 2, 4, 2) };
+ s.Children.Add(new Border { BorderBrush = Palette.Line, BorderThickness = new Thickness(0, i == 0 ? 0 : 1, 0, 0), Margin = new Thickness(20, 0, 20, 0), Child = cards[i] });
+ return new Border { Background = Palette.Surface, CornerRadius = new CornerRadius(16), Child = s, Padding = new Thickness(0, 2, 0, 2) };
}
/// One setting: icon, name, one grey line, and its control on the right.
static FrameworkElement Card(string? icon, string title, string? description, FrameworkElement control, FrameworkElement? image = null)
{
- var dock = new DockPanel { MinHeight = 48, Margin = new Thickness(16, 10, 16, 10) };
- var lead = image ?? (icon is null ? new Border { Width = 20 } : Ui.Icon(icon, 20, Palette.Body));
- lead.Margin = new Thickness(0, 0, 16, 0);
- DockPanel.SetDock(lead, Dock.Left);
- dock.Children.Add(lead);
+ // No icons: the Mac's rows are words and a control. (`icon` stays for the call sites.)
+ _ = icon;
+ var dock = new DockPanel { MinHeight = 40, Margin = new Thickness(0, 10, 0, 10) };
+ if (image is not null) { image.Margin = new Thickness(0, 0, 14, 0); DockPanel.SetDock(image, Dock.Left); dock.Children.Add(image); }
control.VerticalAlignment = VerticalAlignment.Center;
control.Margin = new Thickness(16, 0, 0, 0);
DockPanel.SetDock(control, Dock.Right);
@@ -176,12 +179,12 @@ sealed class SettingsWindow : Window
return Group(cards.ToArray());
}
- FrameworkElement SpeakCards()
+ IEnumerable<FrameworkElement> SpeakCards()
{
var s = app.Settings;
var cable = Endpoints.Cable() is not null;
FrameworkElement cableControl = cable
- ? Ui.Row(6, new System.Windows.Controls.Grid { Width = 16, Height = 16, Children = { new System.Windows.Shapes.Ellipse { Fill = Palette.Success }, Ui.Icon(Icons.Check, 16, Brushes.White, stroke: 2) } }, Ui.Text(L("已装好"), 13, Palette.Success, wrap: false))
+ ? new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(10), Padding = new Thickness(12, 7, 12, 8), Child = Ui.Row(8, Ui.Dot(Palette.Success, 7), Ui.Text(L("VB-Cable 已装好"), 13, Palette.Ink, wrap: false)) }
: cableProgress is { } busy ? Ui.Text(busy, 13, Palette.Secondary, wrap: false)
: Ui.Button(L("安装"), () => _ = InstallCable(), Ui.Kind.Primary, height: 32);
var target = app.Speak.Target;
@@ -191,13 +194,16 @@ sealed class SettingsWindow : Window
Ui.Choice(voices, chosen, v => { s.SpeakVoices[VoiceCatalog.Key(target)] = v; Save(); }, 280),
Ui.Button(L("试听"), () => _ = app.Preview(target), height: 32));
var mine = Languages.Sources.FirstOrDefault(x => x.Code == Languages.FromSystem(System.Globalization.CultureInfo.CurrentUICulture.Name))?.Name ?? "";
- return Group(
- Card(Icons.Mic, L("同声传译"), LF("按住%@说话,对方听到的是翻译后的声音", PushToTalk.Label), Ui.Switch(s.Speak, v => { s.Speak = v; Save(); }, L("同声传译"))),
- Card(Icons.Speaker, L("虚拟麦克风"), cable ? L("在会议软件里把麦克风选成 CABLE Output") : L("需要装免费的 VB-Cable;装的时候 Windows 会请你确认"), cableControl),
+ yield return Label(L("说话"));
+ yield return Group(
+ Card(null, L("按住说话"), LF("按住%@说话,对方听到的是翻译后的声音", PushToTalk.Label), Ui.Keycap(PushToTalk.Label, big: true)),
Card(null, L("我说的语言"), null, Ui.Choice([("system", LF("跟随系统(%@)", mine)), .. Languages.Sources.Select(x => (x.Code, x.Name))], s.SpeakFrom, v => { s.SpeakFrom = v; Save(); Render(); })),
Card(null, L("对方听到的语言"), s.SpeakTo == "room" ? LF("现在是 %@", Ui.TargetName(target)) : null,
Ui.Choice([("room", L("对方说的语言")), .. Languages.Targets.Select(t => (t.Code, t.Name))], s.SpeakTo, v => { s.SpeakTo = v; Save(); Render(); })),
Card(null, LF("对方听到的声音(%@)", Ui.TargetName(target)), null, voice));
+ yield return Label(L("麦克风"));
+ yield return Group(
+ Card(null, L("译文送进会议"), cable ? L("在会议软件里把麦克风选成 CABLE Output") : L("需要装免费的 VB-Cable;装的时候 Windows 会请你确认"), cableControl));
}
async Task InstallCable()
@@ -258,14 +264,7 @@ sealed class SettingsWindow : Window
static FrameworkElement Keys(string combo)
{
- var row = new StackPanel { Orientation = Orientation.Horizontal };
- foreach (var k in combo.Split('+'))
- row.Children.Add(new Border
- {
- Background = Palette.SurfaceAlt, BorderBrush = Palette.ControlStroke, BorderThickness = new Thickness(1, 1, 1, 2), CornerRadius = new CornerRadius(4),
- Padding = new Thickness(8, 3, 8, 3), Margin = new Thickness(4, 0, 0, 0), Child = Ui.Text(k, 12, Palette.Ink, wrap: false),
- });
- return row;
+ return Ui.Shortcut(combo);
}
void Save() { app.Settings.Save(); app.SettingsChanged(); }
diff --git a/windows/src/Cicada/SpeakBar.cs b/windows/src/Cicada/SpeakBar.cs
index 142fb00..ec09c10 100644
--- a/windows/src/Cicada/SpeakBar.cs
+++ b/windows/src/Cicada/SpeakBar.cs
@@ -6,8 +6,8 @@ using static Cicada.Strings;
namespace Cicada.App;
-/// The bar while I speak: 正在听你说 while the key is held, then what I said and what the room
-/// heard, or why nothing went out. Like the notes panel it never takes focus and stays out of
+/// The pill while I speak: the key, a level, 正在听你说 while it's held, then what I said and what
+/// the room heard, or why nothing went out. Like the notes panel it never takes focus and stays out of
/// screen captures; it sits above the taskbar (above the subtitle bar when that is showing).
sealed class SpeakBar : Window
{
@@ -19,13 +19,13 @@ sealed class SpeakBar : Window
{
this.app = app;
WindowStyle = WindowStyle.None; AllowsTransparency = true; Background = Brushes.Transparent; Topmost = true; ShowInTaskbar = false; ShowActivated = false;
- ResizeMode = ResizeMode.NoResize; SizeToContent = SizeToContent.Height; Width = 560 + 2 * Ui.ShadowRoom; FontFamily = Palette.Font; Title = L("知了");
+ ResizeMode = ResizeMode.NoResize; SizeToContent = SizeToContent.WidthAndHeight; MaxWidth = 600 + 2 * Ui.ShadowRoom; FontFamily = Palette.Font; Title = L("知了");
SourceInitialized += (_, _) =>
{
Native.MakeNonActivating(this);
Native.SetCaptureVisible(this, app.Settings.ShowInCapture);
};
- Content = Ui.Floating(new Border { Padding = new Thickness(18, 12, 18, 14), Child = body }, new SolidColorBrush(Color.FromArgb(0xF0, 0x15, 0x17, 0x1C)), 14, dark: true);
+ Content = Ui.Floating(new Border { Padding = new Thickness(8, 8, 18, 8), Child = body, MinHeight = 44 }, new SolidColorBrush(Color.FromArgb(0xF2, 0x15, 0x17, 0x1C)), 22, dark: true);
SizeChanged += (_, _) => Place();
hide.Tick += (_, _) => { hide.Stop(); Hide(); };
}
@@ -42,35 +42,55 @@ sealed class SpeakBar : Window
{
var s = app.Speak;
hide.Stop();
- var stack = new StackPanel();
+ FrameworkElement content;
+ var target = Ui.Text(LF("对方听到 %@", Ui.TargetName(s.Target)), 13, Palette.NightText, wrap: false);
switch (s.State)
{
case SpeakEngine.Phase.Recording:
- stack.Children.Add(Ui.Row(10, Ui.LiveDot(10), Ui.Text(L("正在听你说 · 松开发送"), 15, Brushes.White, FontWeights.SemiBold, wrap: false)));
- stack.Children.Add(Gap(Ui.Text(LF("对方会听到%@", Ui.TargetName(s.Target)), 12, Palette.NightText), 4));
+ content = Ui.Row(12, Key(true), Wave(), Ui.Text(L("正在听你说 · 松开发送"), 14, Brushes.White, FontWeights.Bold, wrap: false), target);
break;
case SpeakEngine.Phase.Translating:
- stack.Children.Add(Ui.Text(L("正在翻译…"), 15, Brushes.White, FontWeights.SemiBold, wrap: false));
+ content = Ui.Row(12, Key(false), Ui.Text(L("正在翻译…"), 14, Brushes.White, FontWeights.Bold, wrap: false), target);
break;
case SpeakEngine.Phase.Speaking or SpeakEngine.Phase.Idle when s.Heard is not null:
- if (s.Said is not null) stack.Children.Add(Ui.Text(s.Said, 13, Palette.NightText));
- stack.Children.Add(Gap(Ui.Text(s.Heard!, 18, Brushes.White, FontWeights.SemiBold), 4));
- stack.Children.Add(Gap(Ui.Text(s.State == SpeakEngine.Phase.Speaking ? L("正在说给对方听…") : L("对方已听到"), 12, Palette.NightText), 6));
+ var said = new StackPanel { VerticalAlignment = VerticalAlignment.Center, MaxWidth = 480 };
+ if (s.Said is not null) said.Children.Add(Ui.Text(s.Said, 12, Palette.NightText));
+ said.Children.Add(Gap(Ui.Text(s.Heard!, 15, Brushes.White, FontWeights.Bold), s.Said is null ? 0 : 2));
+ var done = s.State == SpeakEngine.Phase.Speaking ? L("正在说给对方听…") : L("对方已听到");
+ content = Ui.Row(12, Key(false), said, Ui.Text(done, 12, Palette.NightText, wrap: false));
if (s.State == SpeakEngine.Phase.Idle) hide.Start();
break;
case SpeakEngine.Phase.Failed:
- if (s.Said is not null) stack.Children.Add(Ui.Text(s.Said, 13, Palette.NightText));
- stack.Children.Add(Gap(Ui.Text(s.Problem ?? L("没翻译成功,没有发出去"), 15, new SolidColorBrush(Color.FromRgb(0xFF, 0x9B, 0x78)), FontWeights.SemiBold), 4));
+ var why = Ui.Text(s.Problem ?? L("没翻译成功,没有发出去"), 14, new SolidColorBrush(Color.FromRgb(0xFF, 0x9B, 0x78)), FontWeights.Bold);
+ why.MaxWidth = 480;
+ content = Ui.Row(12, Key(false), why);
hide.Start();
break;
default:
Hide();
return;
}
- body.Content = stack;
+ body.Content = content;
if (!IsVisible) Show();
Place();
}
+ /// 右 Ctrl as a pill: the accent while held, a dim one after.
+ static FrameworkElement Key(bool held) => new Border
+ {
+ CornerRadius = new CornerRadius(14), Padding = new Thickness(11, 4, 11, 5), VerticalAlignment = VerticalAlignment.Center,
+ Background = held ? Palette.Live : new SolidColorBrush(Color.FromArgb(0x26, 0xFF, 0xFF, 0xFF)),
+ Child = Ui.Text(PushToTalk.Label, 13, Brushes.White, FontWeights.Bold, wrap: false),
+ };
+
+ /// A still level mark: an animated one would redraw this software-rendered window every frame.
+ static FrameworkElement Wave()
+ {
+ var row = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center };
+ foreach (var h in new[] { 6.0, 11, 16, 12, 16, 8 })
+ row.Children.Add(new System.Windows.Shapes.Rectangle { Width = 2.5, Height = h, RadiusX = 1, RadiusY = 1, Fill = Palette.Live, Margin = new Thickness(0, 0, 2.5, 0), VerticalAlignment = VerticalAlignment.Center });
+ return row;
+ }
+
static FrameworkElement Gap(FrameworkElement e, double top) { e.Margin = new Thickness(0, top, 0, 0); return e; }
}
diff --git a/windows/src/Cicada/Strings/en.lproj/Windows.strings b/windows/src/Cicada/Strings/en.lproj/Windows.strings
index c0855e2..9b0ad33 100644
--- a/windows/src/Cicada/Strings/en.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/en.lproj/Windows.strings
@@ -132,3 +132,44 @@
"需要你在 Windows 的提示里点“是”才能安装。" = "Select Yes in the Windows prompt to install.";
"需要装免费的 VB-Cable;装的时候 Windows 会请你确认" = "Requires the free VB-Cable driver. Windows will ask you to confirm.";
"麦克风打不开" = "Couldn't open the microphone";
+"key 加密存在这台电脑上,只发给 Ling" = "The key is stored encrypted on this PC and only sent to Ling";
+"开始用" = "Start using Cicada";
+"音量条没动?放段视频或音乐试试" = "Meter not moving? Play a video or some music";
+"以后再说" = "Not now";
+"已连接,可以用了" = "Connected, ready to use";
+"默认扬声器" = "Default speakers";
+"只听声音,不录屏幕画面,也不占麦克风" = "Sound only: no screen recording, and the mic stays free";
+"从哪里听" = "Listening on";
+"纪要窗不会出现在截图和屏幕共享里" = "The notes window stays out of screenshots and screen sharing";
+"字幕和纪要都从这里来。Windows 上不用授权,放点声音就行。" = "Subtitles and notes come from here. Windows asks for no permission: just play some sound.";
+"已收到声音" = "Sound coming in";
+"看右边的纪要窗" = "Watch the notes window on the right";
+"字幕和纪要一句句出来;点它不会抢走你正在用的窗口" = "Lines and notes appear as they're spoken; clicking it won't take focus from your app";
+"看看效果" = "See it work";
+"装一个虚拟麦克风" = "Install a virtual microphone";
+"VB-Cable,免费,Windows 会问一次是否允许" = "VB-Cable, free. Windows asks once to allow it";
+"会议软件里,麦克风选 CABLE Output" = "In your meeting app, pick CABLE Output as the microphone";
+"Teams、Zoom、腾讯会议都在“音频设置”里" = "In Teams, Zoom and Tencent Meeting it's under audio settings";
+"按住说一句试试" = "Hold it and say something";
+"松开后约 2 秒,对方就会听到译文" = "About 2 seconds after you let go, the room hears the translation";
+"要让对方听懂你说的话吗?" = "Want the room to understand you?";
+"按住%@说话,对方在会议里听到翻译后的声音。不需要可以跳过。" = "Hold %@ and speak; the meeting hears you translated. Skip it if you don't need it.";
+"打开任务栏设置" = "Open taskbar settings";
+"拖不动?在任务栏设置里打开“知了”" = "Can't drag it? Turn on Cicada in taskbar settings";
+"在哪儿都能用" = "Works from anywhere";
+"开始 / 结束听" = "Start / stop listening";
+"好了,知了住在任务栏右下角" = "All set: Cicada lives at the bottom right of the taskbar";
+"Windows 会先把新图标收进 ^ 里。拖出来放在时钟旁边,开会时一眼就能看到。" = "Windows tucks new icons under ^ at first. Drag it out next to the clock so it's in sight during meetings.";
+"最大化" = "Maximize";
+"隐藏纪要窗" = "Hide notes window";
+"退出知了" = "Quit Cicada";
+"知了还在任务栏右下角" = "Cicada is still in the taskbar corner";
+"关掉窗口不会退出,按 %@ 随时开始听。" = "Closing the window doesn't quit. Press %@ to start listening any time.";
+"共享屏幕时对方看得到" = "Visible when you share your screen";
+"VB-Cable 已装好" = "VB-Cable installed";
+"译文送进会议" = "Send the translation into the meeting";
+"没在听" = "Not listening";
+"对方听得到" = "The room can hear you";
+"去设置" = "Settings";
+"听电脑里的声音" = "Hear this PC's audio";
+"让知了听到电脑里的声音" = "Let Cicada hear your PC";
diff --git a/windows/src/Cicada/Strings/ja.lproj/Windows.strings b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
index ba11b56..569cbbb 100644
--- a/windows/src/Cicada/Strings/ja.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
@@ -132,3 +132,44 @@
"需要你在 Windows 的提示里点“是”才能安装。" = "インストールするには、Windows の確認画面で「はい」を選んでください。";
"需要装免费的 VB-Cable;装的时候 Windows 会请你确认" = "無料の VB-Cable が必要です。インストール時に Windows の確認画面が出ます";
"麦克风打不开" = "マイクを開けません";
+"key 加密存在这台电脑上,只发给 Ling" = "キーはこのPCに暗号化して保存され、Lingにだけ送られます";
+"开始用" = "使い始める";
+"音量条没动?放段视频或音乐试试" = "メーターが動かない?動画か音楽を流してみて";
+"以后再说" = "あとで";
+"已连接,可以用了" = "接続しました。使えます";
+"默认扬声器" = "既定のスピーカー";
+"只听声音,不录屏幕画面,也不占麦克风" = "音声だけ。画面は録画せず、マイクも使いません";
+"从哪里听" = "聞く場所";
+"纪要窗不会出现在截图和屏幕共享里" = "メモウィンドウはスクリーンショットや画面共有に映りません";
+"字幕和纪要都从这里来。Windows 上不用授权,放点声音就行。" = "字幕とメモはここから生まれます。Windowsでは許可は不要、音を流すだけです。";
+"已收到声音" = "音声を受信中";
+"看右边的纪要窗" = "右のメモウィンドウを見る";
+"字幕和纪要一句句出来;点它不会抢走你正在用的窗口" = "字幕とメモが一文ずつ現れます。クリックしても今のウィンドウのフォーカスは奪いません";
+"看看效果" = "試してみる";
+"装一个虚拟麦克风" = "仮想マイクを入れる";
+"VB-Cable,免费,Windows 会问一次是否允许" = "VB-Cable(無料)。Windowsが一度だけ許可を求めます";
+"会议软件里,麦克风选 CABLE Output" = "会議アプリでマイクを CABLE Output にする";
+"Teams、Zoom、腾讯会议都在“音频设置”里" = "Teams、Zoom、Tencent Meeting では「オーディオ設定」にあります";
+"按住说一句试试" = "押しながら話してみる";
+"松开后约 2 秒,对方就会听到译文" = "離して約2秒で、相手に翻訳が聞こえます";
+"要让对方听懂你说的话吗?" = "相手にあなたの言葉を伝えますか?";
+"按住%@说话,对方在会议里听到翻译后的声音。不需要可以跳过。" = "%@ を押しながら話すと、会議では翻訳された声が流れます。不要ならスキップできます。";
+"打开任务栏设置" = "タスクバーの設定を開く";
+"拖不动?在任务栏设置里打开“知了”" = "ドラッグできない?タスクバーの設定で Cicada をオンに";
+"在哪儿都能用" = "どこからでも";
+"开始 / 结束听" = "聞く/終える";
+"好了,知了住在任务栏右下角" = "完了。Cicada はタスクバーの右下にいます";
+"Windows 会先把新图标收进 ^ 里。拖出来放在时钟旁边,开会时一眼就能看到。" = "Windows は新しいアイコンをまず ^ の中にしまいます。時計の横にドラッグすれば、会議中すぐ見つかります。";
+"最大化" = "最大化";
+"隐藏纪要窗" = "メモウィンドウを隠す";
+"退出知了" = "Cicada を終了";
+"知了还在任务栏右下角" = "Cicada はタスクバーの右下にいます";
+"关掉窗口不会退出,按 %@ 随时开始听。" = "ウィンドウを閉じても終了しません。%@ でいつでも聞き始められます。";
+"共享屏幕时对方看得到" = "画面共有で相手に見えます";
+"VB-Cable 已装好" = "VB-Cable 導入済み";
+"译文送进会议" = "翻訳を会議に流す";
+"没在听" = "聞いていません";
+"对方听得到" = "相手に聞こえます";
+"去设置" = "設定へ";
+"听电脑里的声音" = "PC の音声を聞く";
+"让知了听到电脑里的声音" = "Cicada に PC の音を聞かせる";
diff --git a/windows/src/Cicada/Strings/ko.lproj/Windows.strings b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
index 377985c..0be98ba 100644
--- a/windows/src/Cicada/Strings/ko.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
@@ -132,3 +132,44 @@
"需要你在 Windows 的提示里点“是”才能安装。" = "설치하려면 Windows 알림 창에서 '예'를 눌러야 합니다.";
"需要装免费的 VB-Cable;装的时候 Windows 会请你确认" = "무료 VB-Cable 설치가 필요합니다. 설치할 때 Windows에서 확인을 요청합니다";
"麦克风打不开" = "마이크를 열 수 없습니다";
+"key 加密存在这台电脑上,只发给 Ling" = "키는 이 PC에 암호화되어 저장되고 Ling에만 전송됩니다";
+"开始用" = "시작하기";
+"音量条没动?放段视频或音乐试试" = "미터가 안 움직이나요? 영상이나 음악을 틀어 보세요";
+"以后再说" = "나중에";
+"已连接,可以用了" = "연결됨, 바로 쓸 수 있어요";
+"默认扬声器" = "기본 스피커";
+"只听声音,不录屏幕画面,也不占麦克风" = "소리만 들어요. 화면은 녹화하지 않고 마이크도 쓰지 않아요";
+"从哪里听" = "듣는 곳";
+"纪要窗不会出现在截图和屏幕共享里" = "노트 창은 스크린샷과 화면 공유에 나오지 않아요";
+"字幕和纪要都从这里来。Windows 上不用授权,放点声音就行。" = "자막과 노트는 여기서 나와요. Windows에서는 권한이 필요 없고 소리만 틀면 돼요.";
+"已收到声音" = "소리가 들어와요";
+"看右边的纪要窗" = "오른쪽 노트 창을 보세요";
+"字幕和纪要一句句出来;点它不会抢走你正在用的窗口" = "자막과 노트가 한 문장씩 나와요. 클릭해도 쓰던 창의 포커스를 뺏지 않아요";
+"看看效果" = "직접 보기";
+"装一个虚拟麦克风" = "가상 마이크 설치";
+"VB-Cable,免费,Windows 会问一次是否允许" = "VB-Cable, 무료. Windows가 한 번 허용할지 물어요";
+"会议软件里,麦克风选 CABLE Output" = "회의 앱에서 마이크를 CABLE Output으로 선택";
+"Teams、Zoom、腾讯会议都在“音频设置”里" = "Teams, Zoom, Tencent Meeting 모두 '오디오 설정'에 있어요";
+"按住说一句试试" = "누른 채로 한마디 해 보세요";
+"松开后约 2 秒,对方就会听到译文" = "떼고 약 2초 뒤 상대가 번역을 들어요";
+"要让对方听懂你说的话吗?" = "상대가 내 말을 알아듣게 할까요?";
+"按住%@说话,对方在会议里听到翻译后的声音。不需要可以跳过。" = "%@ 키를 누른 채 말하면 회의에서는 번역된 목소리가 들려요. 필요 없으면 건너뛰세요.";
+"打开任务栏设置" = "작업 표시줄 설정 열기";
+"拖不动?在任务栏设置里打开“知了”" = "드래그가 안 되나요? 작업 표시줄 설정에서 Cicada를 켜세요";
+"在哪儿都能用" = "어디서나";
+"开始 / 结束听" = "듣기 시작 / 끝내기";
+"好了,知了住在任务栏右下角" = "다 됐어요. Cicada는 작업 표시줄 오른쪽 아래에 있어요";
+"Windows 会先把新图标收进 ^ 里。拖出来放在时钟旁边,开会时一眼就能看到。" = "Windows는 새 아이콘을 먼저 ^ 안에 넣어요. 시계 옆으로 끌어 놓으면 회의 중에 바로 보여요.";
+"最大化" = "최대화";
+"隐藏纪要窗" = "노트 창 숨기기";
+"退出知了" = "Cicada 종료";
+"知了还在任务栏右下角" = "Cicada는 작업 표시줄 오른쪽 아래에 있어요";
+"关掉窗口不会退出,按 %@ 随时开始听。" = "창을 닫아도 종료되지 않아요. 언제든 %@ 키로 듣기를 시작하세요.";
+"共享屏幕时对方看得到" = "화면 공유 시 상대에게 보여요";
+"VB-Cable 已装好" = "VB-Cable 설치됨";
+"译文送进会议" = "번역을 회의로 보내기";
+"没在听" = "듣고 있지 않음";
+"对方听得到" = "상대에게 들려요";
+"去设置" = "설정으로";
+"听电脑里的声音" = "PC 소리 듣기";
+"让知了听到电脑里的声音" = "Cicada가 PC 소리를 듣게 하세요";
diff --git a/windows/src/Cicada/TrayFlyout.cs b/windows/src/Cicada/TrayFlyout.cs
index 186da60..0eb5b2d 100644
--- a/windows/src/Cicada/TrayFlyout.cs
+++ b/windows/src/Cicada/TrayFlyout.cs
@@ -6,8 +6,9 @@ using static Cicada.Strings;
namespace Cicada.App;
-/// Left-click on the tray icon: Cicada's home, the counterpart of the Mac's menu bar panel. It
-/// rises above the notification area like Windows' own flyouts and goes away when it loses focus.
+/// Left-click on the tray icon when not listening (while listening the click shows or hides the
+/// notes window instead, which sits in the same corner): Cicada's home, the counterpart of the
+/// Mac's menu bar panel. It rises above the notification area and goes away when it loses focus.
sealed class TrayFlyout : Window
{
readonly Controller app;
@@ -21,8 +22,8 @@ sealed class TrayFlyout : Window
// The Mac panel's 16-point corners and soft shadow (Ui.Floating), so a transparent window.
WindowStyle = WindowStyle.None; AllowsTransparency = true; Background = Brushes.Transparent;
Topmost = true; ShowInTaskbar = false; ResizeMode = ResizeMode.NoResize;
- Width = 380 + 2 * Ui.ShadowRoom; SizeToContent = SizeToContent.Height; FontFamily = Palette.Font; Title = L("知了");
- Content = Ui.Floating(body, Palette.Page);
+ Width = 360 + 2 * Ui.ShadowRoom; SizeToContent = SizeToContent.Height; FontFamily = Palette.Font; Title = L("知了");
+ Content = Ui.Floating(body, Palette.Surface);
Deactivated += (_, _) => { Hide(); hiddenAt = DateTime.UtcNow; };
KeyDown += (_, e) => { if (e.Key == System.Windows.Input.Key.Escape) Hide(); };
SizeChanged += (_, _) => Anchor();
@@ -42,35 +43,40 @@ sealed class TrayFlyout : Window
Activate();
}
+ /// Next to the notification area, on whichever edge the taskbar is.
void Anchor()
{
var area = SystemParameters.WorkArea;
- Left = area.Right - ActualWidth - 12 + Ui.ShadowRoom;
- Top = area.Bottom - ActualHeight - 12 + Ui.ShadowRoom;
+ Left = area.Left > 0 ? area.Left + 12 - Ui.ShadowRoom : area.Right - ActualWidth - 12 + Ui.ShadowRoom;
+ Top = area.Top > 0 ? area.Top + 12 - Ui.ShadowRoom : area.Bottom - ActualHeight - 12 + Ui.ShadowRoom;
}
public void Refresh() => body.Content = Build();
+ void Do(Action act) { Hide(); act(); }
+
+ // The Mac's menu bar panel (Views.swift › MenuPanel): who and how it is, the one big button,
+ // the choices made before a meeting on grey rows, 同声传译, what shows while listening, and two
+ // buttons at the bottom. Two weights only (Palette.Strong).
FrameworkElement Build()
{
var listen = app.Listen;
- var stack = new StackPanel();
+ var s = app.Settings;
+ var stack = new StackPanel { Margin = new Thickness(18, 18, 18, 18) };
- // Who and how it is
var status = listen.Listening && listen.SessionId is { } sid && app.Store.Get(sid) is { } live
- ? Ui.Row(6, Ui.LiveDot(6), Ui.Text($"{L("正在听")} {Languages.Clock((DateTimeOffset.Now - live.StartedAt).TotalSeconds)}", 12, Palette.Secondary, wrap: false))
+ ? Ui.Row(6, Ui.LiveDot(6), Ui.Text($"{L("正在听")} {Languages.Clock((DateTimeOffset.Now - live.StartedAt).TotalSeconds)}", 13, Palette.Secondary, wrap: false))
: app.AutoEnded
- ? Ui.Row(6, Ui.Dot(Palette.Tertiary, 6), Ui.Text(L("会议已自动结束"), 12, Palette.Secondary, wrap: false))
+ ? Ui.Row(6, Ui.Dot(Palette.Tertiary, 6), Ui.Text(L("会议已自动结束"), 13, Palette.Secondary, wrap: false))
: app.Ling.HasKey
- ? Ui.Row(6, Ui.Dot(Palette.Success, 6), Ui.Text(L("就绪 · Ling 已连接"), 12, Palette.Secondary, wrap: false))
- : Ui.Row(6, Ui.Dot(Palette.Tertiary, 6), Ui.Text(L("还没接上 Ling"), 12, Palette.Secondary, wrap: false));
- var title = Ui.Row(12, AppIcon.Small(32), Ui.Stack(2, Ui.Text(L("知了"), 15, Palette.Ink, FontWeights.SemiBold, wrap: false), status));
- var head = Ui.Spread(title, Ui.IconButton(Icons.Gear, L("打开设置"), () => { Hide(); app.ShowSettings(); }, Palette.Body, 40, 18));
- head.Margin = new Thickness(16, 16, 12, 12);
+ ? Ui.Row(6, Ui.Dot(Palette.Toggle, 6), Ui.Text(L("没在听"), 13, Palette.Secondary, wrap: false))
+ : Ui.Row(6, Ui.Dot(Palette.Tertiary, 6), Ui.Text(L("还没接上 Ling"), 13, Palette.Secondary, wrap: false));
+ var title = Ui.Row(12, AppIcon.Small(40), Ui.Stack(1, Ui.Text(L("知了"), 17, Palette.Ink, Palette.Strong, wrap: false), status));
+ var head = Ui.Spread(title, Ui.IconButton(Icons.Gear, L("打开设置"), () => Do(app.ShowSettings), Palette.Body, 36, 18));
stack.Children.Add(head);
// The one thing to do
- var main = new StackPanel { Margin = new Thickness(16, 4, 16, 16) };
+ var main = new StackPanel { Margin = new Thickness(0, 18, 0, 0) };
if (listen.Listening && app.Ending is { } p)
{
// About to end by itself (MeetingEndingStrip, compact): the panel takes no focus either.
@@ -88,88 +94,149 @@ sealed class TrayFlyout : Window
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });
grid.ColumnDefinitions.Add(new ColumnDefinition());
- var end = Ui.Button(L("结束"), () => { Hide(); app.RequestStop(); }, Ui.Kind.Pale, Icons.Stop, 44, iconFill: true);
- var show = Ui.Button(L("显示纪要"), () => { Hide(); app.ShowNotes(); }, Ui.Kind.Standard, Icons.Notes, 44);
+ var end = Ui.Button(L("结束"), () => Do(app.RequestStop), Ui.Kind.Pale, Icons.Stop, 48, iconFill: true);
+ var showing = app.NotesVisible;
+ var show = Ui.Button(showing ? L("隐藏纪要窗") : L("显示纪要"), () => Do(app.ToggleNotes), Ui.Kind.Standard, Icons.Notes, 48);
Grid.SetColumn(show, 2);
grid.Children.Add(end); grid.Children.Add(show);
main.Children.Add(grid);
}
else
{
- main.Children.Add(Ui.Button(L("开始听"), () => { Hide(); _ = app.ToggleListening(); }, Ui.Kind.Accent, Icons.Wave, 52));
- var hint = Ui.Text(app.Settings.Speak ? $"{Hotkey.Label} · {LF("按住%@说话", PushToTalk.Label)}" : $"{L("听电脑播放的声音,不用麦克风")} · {Hotkey.Label}", 12, Palette.Secondary);
- hint.TextAlignment = TextAlignment.Center; hint.Margin = new Thickness(0, 8, 0, 0);
- main.Children.Add(hint);
+ var label = Ui.Row(10, Ui.Dot(Palette.Live, 8), Ui.Text(L("开始听"), 15, Brushes.White, Palette.Strong, wrap: false), DarkKey(Hotkey.Label.Replace('+', ' ')));
+ var start = new Button { Content = label, Height = 48, HorizontalAlignment = HorizontalAlignment.Stretch, Background = Palette.Ink, BorderThickness = new Thickness(0), Cursor = System.Windows.Input.Cursors.Hand, HorizontalContentAlignment = HorizontalAlignment.Center };
+ start.Template = Surface(12, dim: true);
+ start.Click += (_, _) => Do(() => _ = app.ToggleListening());
+ System.Windows.Automation.AutomationProperties.SetName(start, L("开始听"));
+ main.Children.Add(start);
}
stack.Children.Add(main);
- // Two choices people change before a meeting
- var target = Ui.Choice(Ui.TargetOptions(), app.Settings.Target, app.SetTarget, 212);
- var view = Ui.Segmented([("notes", L("纪要")), ("subtitles", L("字幕条"))], app.Settings.View, app.SetView);
- var options = new StackPanel
- {
- Children =
- {
- OptionRow(Icons.Globe, L("翻译成"), target, divider: true),
- OptionRow(Icons.Subtitles, L("听的时候显示"), view, divider: false),
- },
- };
- stack.Children.Add(new Border { Margin = new Thickness(12, 0, 12, 0), Background = Palette.Surface, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8), Child = options });
+ // The choice people change before a meeting
+ var spoken = Languages.Targets.FirstOrDefault(t => t.Code == Languages.FromSystem(System.Globalization.CultureInfo.CurrentUICulture.Name))?.Code;
+ var target = s.Target == "system" ? spoken ?? "zh-Hans" : s.Target;
+ stack.Children.Add(Gap(ChoiceRow(L("翻译成"), Ui.TargetName(target), s.Target == "system" ? L("跟随系统") : null, Ui.TargetOptions(), s.Target, app.SetTarget), 12));
+
+ // 同声传译
+ stack.Children.Add(Rule());
+ var cable = Endpoints.Cable() is not null;
+ var speakState = s.Speak && cable && app.Ling.HasKey
+ ? (UIElement)Ui.Text(L("对方听得到"), 12, Palette.Success, wrap: false)
+ : Ui.LinkText(s.Speak ? L("去设置") : L("打开"), () => Do(app.ShowSettings), 12);
+ stack.Children.Add(Ui.Spread(Ui.Text(L("同声传译"), 14, Palette.Ink, Palette.Strong, wrap: false), speakState));
+ var talk = Ui.Row(12, Ui.Keycap(PushToTalk.Label, big: false), Ui.Stack(1,
+ Ui.Text(s.Speak ? LF("按住%@说话", PushToTalk.Label) : L("同声传译没打开"), 14, Palette.Ink, wrap: false),
+ Ui.Text(LF("对方听到 %@", Ui.TargetName(app.Speak.Target)), 12, Palette.Secondary, wrap: false)));
+ stack.Children.Add(Gap(new Border { BorderBrush = Palette.Line, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(12), Padding = new Thickness(12, 10, 12, 10), Child = talk, Opacity = s.Speak ? 1 : 0.7 }, 10));
+
+ // What shows while listening
+ stack.Children.Add(Rule());
+ stack.Children.Add(Ui.Text(L("听的时候显示"), 14, Palette.Ink, Palette.Strong, wrap: false));
+ var tiles = new System.Windows.Controls.Primitives.UniformGrid { Rows = 1, Margin = new Thickness(0, 10, 0, 0) };
+ tiles.Children.Add(Tile("notes", L("纪要"), NotesPicture()));
+ tiles.Children.Add(Tile("subtitles", L("字幕条"), BarPicture()));
+ stack.Children.Add(tiles);
+
+ // Two buttons along the bottom
+ stack.Children.Add(Rule());
+ var foot = new Grid();
+ foot.ColumnDefinitions.Add(new ColumnDefinition());
+ foot.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });
+ foot.ColumnDefinitions.Add(new ColumnDefinition());
+ var records = Ui.Button(L("会议记录"), () => Do(app.ShowRecords), Ui.Kind.Standard, Icons.Notes, 42);
+ var quit = Ui.Button(L("退出"), () => Do(() => _ = app.Quit()), Ui.Kind.Standard, Icons.Power, 42);
+ Grid.SetColumn(quit, 2);
+ foot.Children.Add(records); foot.Children.Add(quit);
+ stack.Children.Add(foot);
+ return stack;
+ }
+
+ static FrameworkElement Gap(FrameworkElement e, double top) { e.Margin = new Thickness(e.Margin.Left, top, e.Margin.Right, e.Margin.Bottom); return e; }
+
+ static FrameworkElement Rule() => new Border { Height = 1, Background = Palette.Line, Margin = new Thickness(0, 16, 0, 16) };
- // Recent meetings
- var recent = app.Store.All().Where(s => !(listen.Listening && s.Id == listen.SessionId)).Take(3).ToList();
- if (recent.Count > 0)
+ /// The shortcut inside the ink button: a keycap drawn for a dark ground.
+ static FrameworkElement DarkKey(string keys) => new Border
+ {
+ BorderBrush = new SolidColorBrush(Color.FromArgb(0x55, 0xFF, 0xFF, 0xFF)), BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(5),
+ Padding = new Thickness(6, 1, 6, 2), Child = Ui.Text(keys, 12, Palette.NightText, wrap: false),
+ };
+
+ /// A grey row: what it is on the left in grey, the choice in ink with maybe a pale tag, a chevron;
+ /// a click opens the choices.
+ FrameworkElement ChoiceRow(string label, string value, string? tag, IEnumerable<(string value, string label)> options, string selected, Action<string> changed)
+ {
+ var name = Ui.Text(label, 13, Palette.Secondary, wrap: false);
+ name.MinWidth = 76; name.Margin = new Thickness(0, 0, 12, 0); // "Translate to" runs wider than 翻译成
+ var shown = Ui.Row(8, Ui.Text(value, 15, Palette.Ink, wrap: false));
+ if (tag is not null) ((StackPanel)shown).Children.Add(Gap2(Ui.Badge(tag)));
+ var chevron = Ui.Icon(Icons.Chevron, 14, Palette.Secondary, stroke: 1.6);
+ var dock = new DockPanel();
+ DockPanel.SetDock(name, Dock.Left); DockPanel.SetDock(chevron, Dock.Right);
+ dock.Children.Add(name); dock.Children.Add(chevron); dock.Children.Add(shown);
+ name.VerticalAlignment = VerticalAlignment.Center;
+ var b = new Button { Content = dock, Height = 52, HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(14, 0, 14, 0), Background = Palette.Mica, BorderThickness = new Thickness(0), Cursor = System.Windows.Input.Cursors.Hand, HorizontalContentAlignment = HorizontalAlignment.Stretch };
+ b.Template = Surface(12, dim: false);
+ b.Click += (_, _) =>
{
- var label = Ui.Spread(Ui.Text(L("最近的会议"), 13, Palette.Body, FontWeights.SemiBold, wrap: false), Ui.LinkText(L("查看全部"), () => { Hide(); app.ShowRecords(); }));
- label.Margin = new Thickness(16, 18, 16, 6);
- stack.Children.Add(label);
- var list = new StackPanel { Margin = new Thickness(8, 0, 8, 8) };
- foreach (var s in recent)
+ var menu = new ContextMenu { PlacementTarget = b, Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom, FontFamily = Palette.Font, MinWidth = b.ActualWidth };
+ foreach (var (v, text) in options)
{
- var item = new Button
- {
- Content = Ui.Stack(2, Ui.Text(SessionStore.DisplayTitle(s), 14, Palette.Ink, FontWeights.SemiBold, wrap: false), Ui.Text(Records.Meta(s, app), 12, Palette.Secondary, wrap: false)),
- HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Left, Padding = new Thickness(8, 8, 8, 8), Background = Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = System.Windows.Input.Cursors.Hand,
- };
- item.Template = RowTemplate();
- var id = s.Id;
- item.Click += (_, _) => { Hide(); app.ShowRecords(id); };
- list.Children.Add(item);
+ var item = new MenuItem { Header = text, IsCheckable = true, IsChecked = v == selected };
+ item.Click += (_, _) => { changed(v); Refresh(); };
+ menu.Items.Add(item);
}
- stack.Children.Add(list);
- }
-
- // Footer
- var records = Ui.Button(L("查看记录"), () => { Hide(); app.ShowRecords(); }, Ui.Kind.Subtle, Icons.List, 40);
- var quit = Ui.Button(L("退出"), () => { Hide(); _ = app.Quit(); }, Ui.Kind.Subtle, Icons.Power, 40);
- records.MinWidth = 0; quit.MinWidth = 0;
- var foot = Ui.Spread(records, quit);
- foot.Margin = new Thickness(8, 6, 8, 6);
- stack.Children.Add(new Border { Background = Palette.Mica, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(0, 1, 0, 0), Child = foot, Margin = new Thickness(0, recent.Count > 0 ? 0 : 16, 0, 0) });
- return stack;
+ menu.IsOpen = true;
+ };
+ System.Windows.Automation.AutomationProperties.SetName(b, $"{label} {value}");
+ return b;
+ static FrameworkElement Gap2(FrameworkElement e) { e.Margin = new Thickness(8, 0, 0, 0); return e; }
}
- static FrameworkElement OptionRow(string icon, string label, FrameworkElement control, bool divider)
+ /// One of 纪要 / 字幕条: a small picture of what shows on screen, the chosen one outlined in ink.
+ FrameworkElement Tile(string view, string label, FrameworkElement picture)
{
- var left = Ui.Row(12, Ui.Icon(icon, 18, Palette.Body), Ui.Text(label, 14, Palette.Ink, wrap: false));
- var row = Ui.Spread(left, control);
- row.Margin = new Thickness(12, 8, 12, 8);
- return new Border { BorderBrush = Palette.StrokeSoft, BorderThickness = new Thickness(0, 0, 0, divider ? 1 : 0), Child = row, MinHeight = 52 };
+ var on = app.Settings.View == view;
+ var content = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = { picture, Gap(Ui.Text(label, 13, Palette.Ink, wrap: false), 8) } };
+ ((FrameworkElement)content.Children[1]).HorizontalAlignment = HorizontalAlignment.Center;
+ var b = new Button
+ {
+ Content = content, Height = 76, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(view == "notes" ? 0 : 4, 0, view == "notes" ? 4 : 0, 0),
+ Background = on ? Palette.Surface : Palette.Mica, BorderBrush = on ? Palette.Ink : Brushes.Transparent, BorderThickness = new Thickness(on ? 2 : 0),
+ Cursor = System.Windows.Input.Cursors.Hand,
+ };
+ b.Template = Surface(12, dim: false);
+ b.Click += (_, _) => { app.SetView(view); Refresh(); };
+ System.Windows.Automation.AutomationProperties.SetName(b, label);
+ return b;
}
- /// A list row: no fill until the mouse is on it.
- static ControlTemplate RowTemplate()
+ static FrameworkElement NotesPicture() => Frame(new StackPanel { Margin = new Thickness(5, 5, 5, 0), Children = { Bar(16), Bar(12), Bar(14) } });
+ static FrameworkElement BarPicture() => Frame(new Border { Height = 4, Width = 16, CornerRadius = new CornerRadius(1), Background = Palette.Body, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 0, 4) });
+ static FrameworkElement Bar(double w) => new Border { Height = 1.5, Width = w, Background = Palette.Body, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0, 0, 0, 3) };
+ static FrameworkElement Frame(UIElement inside) => new Border
+ {
+ Width = 30, Height = 22, CornerRadius = new CornerRadius(3), BorderBrush = Palette.Secondary, BorderThickness = new Thickness(1.2), Background = Brushes.White,
+ HorizontalAlignment = HorizontalAlignment.Center, Child = inside,
+ };
+
+ /// A button surface with the bound background and border; hover darkens or dims it. The theme's
+ /// Button style aligns left, so every button built on it says Stretch itself.
+ static ControlTemplate Surface(double radius, bool dim)
{
var t = new ControlTemplate(typeof(Button));
var border = new FrameworkElementFactory(typeof(Border), "bg");
- border.SetValue(Border.CornerRadiusProperty, new CornerRadius(6));
- border.SetValue(Border.BackgroundProperty, Brushes.Transparent);
- border.SetBinding(Border.PaddingProperty, new System.Windows.Data.Binding("Padding") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.SetValue(Border.CornerRadiusProperty, new CornerRadius(radius));
+ foreach (var (dp, path) in new[] { (Border.BackgroundProperty, "Background"), (Border.BorderBrushProperty, "BorderBrush"), (Border.BorderThicknessProperty, "BorderThickness"), (Border.PaddingProperty, "Padding") })
+ border.SetBinding(dp, new System.Windows.Data.Binding(path) { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
var content = new FrameworkElementFactory(typeof(ContentPresenter));
+ content.SetBinding(ContentPresenter.HorizontalAlignmentProperty, new System.Windows.Data.Binding("HorizontalContentAlignment") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ content.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
border.AppendChild(content);
t.VisualTree = border;
var hover = new Trigger { Property = UIElement.IsMouseOverProperty, Value = true };
- hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Subtle, "bg"));
+ if (dim) hover.Setters.Add(new Setter(UIElement.OpacityProperty, 0.9));
+ else hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Selected, "bg"));
t.Triggers.Add(hover);
return t;
}
diff --git a/windows/src/Cicada/Ui.cs b/windows/src/Cicada/Ui.cs
index e40d6c0..2c6e450 100644
--- a/windows/src/Cicada/Ui.cs
+++ b/windows/src/Cicada/Ui.cs
@@ -50,6 +50,10 @@ static class Palette
static readonly SolidColorBrush[] inks = [B(0x0F7B6C), B(0x7A4CC2), B(0xB03A7A), B(0x8A5A00)];
public static SolidColorBrush Speaker(int n) => inks[(Math.Max(1, n) - 1) % inks.Length];
public static readonly FontFamily Font = new("Segoe UI Variable Text, Segoe UI, Microsoft YaHei UI, Yu Gothic UI, Malgun Gothic");
+ /// Two weights only. Microsoft YaHei UI, which draws all the Chinese, has Regular and Bold and
+ /// nothing between: a semibold label renders Bold and the window reads black and cramped. So
+ /// levels come from size and grey, and Bold is for headings and the one main button.
+ public static readonly FontWeight Strong = FontWeights.Bold;
}
/// Stroke icons on a 20×20 grid (Fluent's outline style), drawn with Ui.Icon.
@@ -81,6 +85,8 @@ static class Icons
public const string Check = "M4.5,10.5 L8,14 L15.5,6";
public const string Info = "M17,10 A7,7 0 1 1 3,10 A7,7 0 1 1 17,10 Z M10,9 V14 M10,6.5 V7";
public const string Mic = "M10,2.5 A2.5,2.5 0 0 1 12.5,5 V10 A2.5,2.5 0 0 1 7.5,10 V5 A2.5,2.5 0 0 1 10,2.5 Z M5,9.5 A5,5 0 0 0 15,9.5 M10,14.5 V17.5";
+ public const string Lock = "M5.5,9 H14.5 V16.5 H5.5 Z M7.5,9 V6.5 A2.5,2.5 0 0 1 12.5,6.5 V9";
+ public const string Arrow = "M4,10 H15.5 M11,5.5 L15.5,10 L11,14.5";
public const string OpenExternal = "M8,4 H4.5 V15.5 H16 V12 M11,3.5 H16.5 V9 M16.5,3.5 L9,11";
}
@@ -144,8 +150,8 @@ static class Ui
/// The Mac's buttons (Views.swift › SoftButton and friends): Standard is a soft grey fill with no
/// border, Primary ink, Accent live orange (开始听 only), Subtle no fill until hover, Danger red,
- /// Pale the 结束 pill. Corners 10, or 12 on the big ones; labels semibold.
- public static Button Button(string label, Action onClick, Kind kind = Kind.Standard, string? icon = null, double height = 36, bool iconFill = false)
+ /// Pale the 结束 pill. Corners 10, or 12 on the big ones; filled labels bold, the rest regular.
+ public static Button Button(string label, Action onClick, Kind kind = Kind.Standard, string? icon = null, double height = 36, bool iconFill = false, bool iconAfter = false)
{
var (bg, fg) = kind switch
{
@@ -157,10 +163,12 @@ static class Ui
_ => (Palette.Mica, Palette.Ink),
};
var content = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };
- if (icon is not null) content.Children.Add(Icon(icon, height >= 48 ? 20 : 16, fg, iconFill));
- var text = new TextBlock { Text = label, FontSize = height >= 48 ? 16 : 14, FontWeight = kind == Kind.Subtle ? FontWeights.Normal : FontWeights.SemiBold, FontFamily = Palette.Font, VerticalAlignment = VerticalAlignment.Center, Foreground = fg };
- if (icon is not null) text.Margin = new Thickness(8, 0, 0, 0);
+ var glyph = icon is null ? null : Icon(icon, height >= 48 ? 20 : iconAfter ? 14 : 16, fg, iconFill, stroke: iconAfter ? 1.8 : 1.5);
+ if (glyph is not null && !iconAfter) content.Children.Add(glyph);
+ var text = new TextBlock { Text = label, FontSize = height >= 48 ? 16 : 14, FontWeight = kind is Kind.Primary or Kind.Accent or Kind.Danger ? FontWeights.Bold : FontWeights.Normal, FontFamily = Palette.Font, VerticalAlignment = VerticalAlignment.Center, Foreground = fg };
+ if (glyph is not null && !iconAfter) text.Margin = new Thickness(8, 0, 0, 0);
content.Children.Add(text);
+ if (glyph is not null && iconAfter) { glyph.Margin = new Thickness(8, 0, 0, 0); content.Children.Add(glyph); }
var b = new Button
{
Content = content, Foreground = fg, Background = bg, BorderThickness = new Thickness(0),
@@ -228,7 +236,7 @@ static class Ui
/// window doesn't start a drag instead.
public static TextBlock LinkText(string label, Action onClick, double size = 13)
{
- var t = Text(label, size, Palette.AccentText, FontWeights.SemiBold, wrap: false);
+ var t = Text(label, size, Palette.AccentText, wrap: false);
t.Cursor = Cursors.Hand;
t.MouseLeftButtonDown += (_, e) => { e.Handled = true; onClick(); };
t.MouseEnter += (_, _) => t.TextDecorations = TextDecorations.Underline;
@@ -265,7 +273,7 @@ static class Ui
public static Border Badge(string text, Brush? bg = null, Brush? fg = null) => new()
{
Background = bg ?? Palette.AccentPale, CornerRadius = new CornerRadius(9), Padding = new Thickness(9, 3, 9, 4), VerticalAlignment = VerticalAlignment.Center,
- Child = Text(text, 12, fg ?? Palette.AccentText, FontWeights.SemiBold, wrap: false),
+ Child = Text(text, 12, fg ?? Palette.AccentText, wrap: false),
};
/// Room around a floating window's card for its shadow.
@@ -311,7 +319,7 @@ static class Ui
icon.Children.Add(new Ellipse { Fill = error ? Palette.Danger : Palette.WarnIcon });
icon.Children.Add(Icon(error ? "M7,7 L13,13 M13,7 L7,13" : "M10,5.5 V11 M10,14 V14.5", 18, Brushes.White, stroke: 1.8));
var text = new StackPanel { Margin = new Thickness(10, 0, 8, 0) };
- if (title is not null) text.Children.Add(Text(title, 14, Palette.Ink, FontWeights.SemiBold));
+ if (title is not null) text.Children.Add(Text(title, 14, Palette.Ink, FontWeights.Bold));
var bodyText = Text(body, 13, Palette.Body);
if (title is not null) bodyText.Margin = new Thickness(0, 2, 0, 0);
text.Children.Add(bodyText);
@@ -331,7 +339,7 @@ static class Ui
/// The Mac's switch: an ink track when on, a grey one when off, a white knob; no 开/关 beside it.
public static FrameworkElement Switch(bool on, Action<bool> changed, string name)
{
- var knob = new Ellipse { Width = 18, Height = 18, Fill = Brushes.White, Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 3, ShadowDepth = 1, Opacity = 0.25 } };
+ var knob = new Ellipse { Width = 18, Height = 18, Fill = Brushes.White, Stroke = new SolidColorBrush(Color.FromArgb(0x1A, 0, 0, 0)), StrokeThickness = 0.5 };
var track = new Border { Width = 38, Height = 22, CornerRadius = new CornerRadius(11), Child = knob, Padding = new Thickness(2) };
void Paint(bool v)
{
@@ -347,10 +355,12 @@ static class Ui
}
/// A segmented control: one choice of a few, the chosen one raised on a grey track.
- public static FrameworkElement Segmented(IEnumerable<(string value, string label)> options, string selected, Action<string> changed)
+ /// No blur on the raised one (the notes panel redraws in software): a white fill and a hairline.
+ /// `fill` spreads the options over the full width in equal parts, as the notes panel's 纪要 / 文字记录.
+ public static FrameworkElement Segmented(IEnumerable<(string value, string label)> options, string selected, Action<string> changed, bool fill = false, double height = 30)
{
var track = new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(10), Padding = new Thickness(3) };
- var row = new StackPanel { Orientation = Orientation.Horizontal };
+ Panel row = fill ? new UniformGrid { Rows = 1 } : new StackPanel { Orientation = Orientation.Horizontal };
track.Child = row;
var buttons = new List<(Button b, string v)>();
void Paint(string v)
@@ -359,14 +369,13 @@ static class Ui
{
var on = value == v;
b.Background = on ? Palette.Surface : Brushes.Transparent;
- b.Effect = on ? new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 4, ShadowDepth = 1, Opacity = 0.10 } : null;
- ((TextBlock)b.Content).FontWeight = on ? FontWeights.SemiBold : FontWeights.Normal;
- ((TextBlock)b.Content).Foreground = on ? Palette.Ink : Palette.Body;
+ b.BorderBrush = on ? Palette.Line : Brushes.Transparent;
+ ((TextBlock)b.Content).Foreground = on ? Palette.Ink : Palette.Secondary;
}
}
foreach (var (value, label) in options)
{
- var b = new Button { Content = Text(label, 13, Palette.Body, wrap: false), Height = 30, Padding = new Thickness(14, 0, 14, 0), BorderThickness = new Thickness(0), Cursor = Cursors.Hand };
+ var b = new Button { Content = Text(label, 13, Palette.Body, wrap: false), Height = height, HorizontalAlignment = fill ? HorizontalAlignment.Stretch : HorizontalAlignment.Left, Padding = new Thickness(14, 0, 14, 0), BorderThickness = new Thickness(1), Cursor = Cursors.Hand, HorizontalContentAlignment = HorizontalAlignment.Center };
b.Template = Template(plain: false, radius: 8);
b.Click += (_, _) => { Paint(value); changed(value); };
buttons.Add((b, value));
@@ -383,11 +392,11 @@ static class Ui
foreach (var (value, label) in options)
{
var on = value == selected;
- var text = Text(label, size, on ? Palette.Ink : Palette.Secondary, on ? FontWeights.SemiBold : FontWeights.Normal, wrap: false);
- var underline = new Border { Height = 3, CornerRadius = new CornerRadius(2), Background = on ? Palette.Ink : Brushes.Transparent, Margin = new Thickness(0, 6, 0, 0) };
+ var text = Text(label, size, on ? Palette.Ink : Palette.Secondary, wrap: false);
+ var underline = new Border { Height = 2, CornerRadius = new CornerRadius(1), Background = on ? Palette.Ink : Brushes.Transparent, Margin = new Thickness(0, 8, 0, 0) };
var stack = new StackPanel { Children = { text, underline } };
- var b = new Button { Content = stack, Padding = new Thickness(12, 8, 12, 0), Background = Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = Cursors.Hand };
- b.Template = Template(plain: true);
+ var b = new Button { Content = stack, Padding = new Thickness(0, 8, 0, 0), Margin = new Thickness(0, 0, 24, 0), Background = Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = Cursors.Hand };
+ b.Template = Template(plain: false, radius: 0);
b.Click += (_, _) => changed(value);
row.Children.Add(b);
}
@@ -399,7 +408,7 @@ static class Ui
public static Button Choice(IEnumerable<(string value, string label)> options, string selected, Action<string> changed, double width = 200)
{
var list = options.ToList();
- var label = Text(list.FirstOrDefault(o => o.value == selected).label ?? "", 14, Palette.Ink, FontWeights.SemiBold, wrap: false);
+ var label = Text(list.FirstOrDefault(o => o.value == selected).label ?? "", 14, Palette.Ink, wrap: false);
var chevron = Icon(Icons.Chevron, 14, Palette.Secondary, stroke: 1.8);
var dock = new DockPanel { LastChildFill = true };
DockPanel.SetDock(chevron, Dock.Right);
@@ -459,6 +468,66 @@ static class Ui
return box;
}
+ /// A key as printed on the keyboard (右 Ctrl, Ctrl Alt L): white, a hairline, a thicker bottom
+ /// edge. `big` is the one the user is asked to press.
+ public static Border Keycap(string label, bool big = false) => new()
+ {
+ Background = Brushes.White, BorderBrush = Palette.ControlStroke, BorderThickness = new Thickness(1, 1, 1, big ? 3 : 2),
+ CornerRadius = new CornerRadius(big ? 9 : 6), Padding = big ? new Thickness(18, 8, 18, 7) : new Thickness(7, 2, 7, 2), VerticalAlignment = VerticalAlignment.Center,
+ Child = Text(label, big ? 15 : 12, Palette.Ink, big ? FontWeights.Bold : FontWeights.Normal, wrap: false),
+ };
+
+ /// Shortcut text ("Ctrl+Alt+L") as keycaps: Ctrl Alt L.
+ public static Border Shortcut(string keys) => Keycap(keys.Replace('+', ' '));
+
+ /// A window without Windows' title bar, as the Mac's: the content runs to the top edge and only
+ /// the three caption buttons stay, drawn by us at the top right. WindowChrome keeps what the
+ /// system frame gave: dragging by the top strip, snap, resizing at the edges, and on Windows 11
+ /// DWM's rounded corners and shadow (a one-pixel glass frame).
+ public static FrameworkElement Frameless(Window w, FrameworkElement content, bool resizable = true, double captionHeight = 44, Action? close = null)
+ {
+ System.Windows.Shell.WindowChrome.SetWindowChrome(w, new System.Windows.Shell.WindowChrome
+ {
+ CaptionHeight = captionHeight, ResizeBorderThickness = resizable ? new Thickness(6) : new Thickness(0),
+ GlassFrameThickness = new Thickness(0, 0, 0, 1), CornerRadius = new CornerRadius(0), UseAeroCaptionButtons = false,
+ });
+ var buttons = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top };
+ Button Caption(string glyph, string name, Action act, bool danger = false)
+ {
+ var b = new Button
+ {
+ Content = Icon(glyph, 16, Palette.Body, stroke: 1), Width = 46, Height = 36, Background = Brushes.Transparent, BorderThickness = new Thickness(0),
+ ToolTip = name, Focusable = false,
+ };
+ var t = new ControlTemplate(typeof(Button));
+ var bg = new FrameworkElementFactory(typeof(Border), "bg");
+ bg.SetBinding(Border.BackgroundProperty, new System.Windows.Data.Binding("Background") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ var cp = new FrameworkElementFactory(typeof(ContentPresenter));
+ cp.SetValue(ContentPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Center);
+ cp.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
+ bg.AppendChild(cp);
+ t.VisualTree = bg;
+ var hover = new Trigger { Property = UIElement.IsMouseOverProperty, Value = true };
+ hover.Setters.Add(new Setter(Border.BackgroundProperty, danger ? Palette.Danger : new SolidColorBrush(Color.FromArgb(0x0F, 0, 0, 0)), "bg"));
+ t.Triggers.Add(hover);
+ b.Template = t;
+ if (danger) { b.MouseEnter += (_, _) => b.Content = Icon(glyph, 16, Brushes.White, stroke: 1); b.MouseLeave += (_, _) => b.Content = Icon(glyph, 16, Palette.Body, stroke: 1); }
+ b.Click += (_, _) => act();
+ System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(b, true);
+ AutomationName(b, name);
+ return b;
+ }
+ buttons.Children.Add(Caption("M5,10 H15", L("最小化"), () => w.WindowState = WindowState.Minimized));
+ if (resizable)
+ buttons.Children.Add(Caption("M5.5,5.5 H14.5 V14.5 H5.5 Z", L("最大化"), () => w.WindowState = w.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized));
+ buttons.Children.Add(Caption(Icons.Close, L("关闭"), close ?? w.Close, danger: true));
+ var root = new Grid { Children = { content, buttons } };
+ // Maximized, Windows puts the frame's invisible border off screen; keep the content inside.
+ void Fit() => root.Margin = w.WindowState == WindowState.Maximized ? new Thickness(7) : new Thickness(0);
+ w.StateChanged += (_, _) => Fit();
+ return root;
+ }
+
public static IEnumerable<(string, string)> TargetOptions() =>
[("system", LF("跟随系统(%@)", Languages.Targets.FirstOrDefault(t => t.Code == Languages.FromSystem(System.Globalization.CultureInfo.CurrentUICulture.Name))?.Name ?? "")),
.. Languages.Targets.Select(t => (t.Code, t.Name))];