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): redesign the app on Windows 11 patterns: tray flyout, Fluent menus, Settings-style settings

wquguru2bee4d699a5c
diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.cs
index 73710a7..0800253 100644
--- a/windows/src/Cicada/App.cs
+++ b/windows/src/Cicada/App.cs
@@ -2,6 +2,7 @@ using System.IO.Pipes;
using System.Media;
using System.Text.Json.Nodes;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Threading;
using static Cicada.Strings;
using Forms = System.Windows.Forms;
@@ -18,6 +19,11 @@ static class Program
using var single = new Mutex(true, Paths.Dev ? "com.wquguru.cicada.dev" : "com.wquguru.cicada", out bool first);
if (!first) { Native.LetOthersTakeForeground(); DebugServer.Send("show records"); return 0; }
var app = new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
+ // WPF's own Windows 11 (Fluent) look for the stock controls: menus, combo boxes, text boxes,
+ // check boxes and scroll bars. Light only for now; Cicada draws its own surfaces on top.
+#pragma warning disable WPF0001
+ app.ThemeMode = ThemeMode.Light;
+#pragma warning restore WPF0001
app.DispatcherUnhandledException += (_, e) => { Log.Debug($"ui: unhandled {e.Exception.GetType().Name}: {e.Exception.Message}"); e.Handled = true; };
var controller = new Controller(app);
app.Startup += (_, _) => controller.Launch();
@@ -38,10 +44,15 @@ sealed class Controller
public readonly Translator Translator;
public readonly ListenEngine Listen;
readonly Forms.NotifyIcon tray = new();
+ System.Drawing.Icon? idleIcon, liveIcon;
+ Action? balloonClicked;
+ Hotkey? hotkey;
+ TrayFlyout? flyout;
+ Window? menuHost;
NotesWindow? notesWindow;
MainWindow? mainWindow;
SettingsWindow? settingsWindow;
- Dispatcher Ui => application.Dispatcher;
+ Dispatcher Dispatch => application.Dispatcher;
public Controller(Application application)
{
@@ -68,15 +79,17 @@ sealed class Controller
}
Log.Debug($"app: launch {(Paths.Dev ? "dev" : "release")} {Environment.OSVersion.Version}");
SetUpTray();
+ hotkey = new Hotkey(() => Dispatch.BeginInvoke(() => _ = ToggleListening()));
DebugServer.Start(this);
if (!Settings.Onboarded) new Onboarding(this).Show();
else if (Ling.HasKey) _ = Ling.Check();
}
- void Changed() => Ui.BeginInvoke(() =>
+ void Changed() => Dispatch.BeginInvoke(() =>
{
notesWindow?.Refresh();
mainWindow?.Refresh();
+ if (flyout?.IsVisible == true) flyout.Refresh();
UpdateTray();
});
@@ -84,10 +97,18 @@ sealed class Controller
void SetUpTray()
{
- tray.Icon = LoadIcon();
+ idleIcon = LoadIcon();
+ liveIcon = WithDot(idleIcon);
+ tray.Icon = idleIcon;
tray.Text = L("知了");
tray.Visible = true;
- tray.MouseClick += (_, e) => { if (e.Button == Forms.MouseButtons.Left) Ui.BeginInvoke(ShowNotes); };
+ // Left click: the flyout. Right click: the menu. Both are WPF, so they look like Windows 11.
+ tray.MouseUp += (_, e) =>
+ {
+ if (e.Button == Forms.MouseButtons.Left) Dispatch.BeginInvoke(ShowFlyout);
+ else if (e.Button == Forms.MouseButtons.Right) Dispatch.BeginInvoke(ShowMenu);
+ };
+ tray.BalloonTipClicked += (_, _) => Dispatch.BeginInvoke(() => { balloonClicked?.Invoke(); balloonClicked = null; });
UpdateTray();
}
@@ -96,27 +117,79 @@ sealed class Controller
try
{
var info = Application.GetResourceStream(new Uri("pack://application:,,,/cicada.ico"));
- return new System.Drawing.Icon(info!.Stream);
+ return new System.Drawing.Icon(info!.Stream, 32, 32);
}
catch { return System.Drawing.SystemIcons.Application; }
}
+ /// The tray icon while listening: the logo with the live dot on its corner.
+ static System.Drawing.Icon WithDot(System.Drawing.Icon icon)
+ {
+ using var bmp = new System.Drawing.Bitmap(32, 32);
+ using (var g = System.Drawing.Graphics.FromImage(bmp))
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.DrawIcon(icon, new System.Drawing.Rectangle(0, 0, 32, 32));
+ using var ring = new System.Drawing.SolidBrush(System.Drawing.Color.White);
+ using var dot = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0xE8, 0x55, 0x2B));
+ g.FillEllipse(ring, 16, 16, 16, 16);
+ g.FillEllipse(dot, 19, 19, 10, 10);
+ }
+ return System.Drawing.Icon.FromHandle(bmp.GetHicon());
+ }
+
void UpdateTray()
{
- var menu = new Forms.ContextMenuStrip();
- menu.Items.Add(Listen.Listening ? L("结束") : L("开始听"), null, (_, _) => Ui.BeginInvoke(() => _ = ToggleListening()));
- menu.Items.Add(new Forms.ToolStripSeparator());
- menu.Items.Add(L("显示纪要"), null, (_, _) => Ui.BeginInvoke(ShowNotes));
- menu.Items.Add(L("会议记录"), null, (_, _) => Ui.BeginInvoke(ShowRecords));
- menu.Items.Add(L("设置"), null, (_, _) => Ui.BeginInvoke(ShowSettings));
- menu.Items.Add(new Forms.ToolStripSeparator());
- menu.Items.Add(L("退出"), null, (_, _) => Ui.BeginInvoke(() => _ = Quit()));
- var old = tray.ContextMenuStrip;
- tray.ContextMenuStrip = menu;
- old?.Dispose();
+ tray.Icon = Listen.Listening ? liveIcon : idleIcon;
tray.Text = Listen.Listening ? L("知了") + " · " + L("正在听") : L("知了");
}
+ public void ShowFlyout()
+ {
+ flyout ??= new TrayFlyout(this);
+ flyout.Toggle();
+ }
+
+ /// The right-click menu needs a window of ours in front, or it won't close on an outside click.
+ public void ShowMenu()
+ {
+ 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 item = new MenuItem { Header = label, InputGestureText = keys ?? "" };
+ if (icon is not null) item.Icon = Ui.Icon(icon, 16, Palette.Ink, fill);
+ item.Click += (_, _) => act();
+ return item;
+ }
+ menu.Items.Add(Listen.Listening
+ ? Item(L("结束"), Icons.Stop, () => _ = StopListening(), 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);
+ menu.Items.Add(new Separator());
+ menu.Items.Add(Item(L("查看记录"), Icons.List, () => ShowRecords()));
+ menu.Items.Add(Item(L("打开设置"), Icons.Gear, ShowSettings));
+ menu.Items.Add(new Separator());
+ menu.Items.Add(Item(L("退出"), Icons.Power, () => _ = Quit()));
+ menu.Closed += (_, _) => menuHost.Hide();
+ menu.IsOpen = true;
+ }
+
+ /// A Windows notification from the tray icon; a click on it runs `clicked`.
+ public void Toast(string title, string body, Action? clicked = null)
+ {
+ balloonClicked = clicked;
+ tray.ShowBalloonTip(6000, title, body, Forms.ToolTipIcon.None);
+ Log.Debug("toast: shown");
+ }
+
// MARK: Listening
public async Task ToggleListening()
@@ -133,7 +206,7 @@ sealed class Controller
{
if (reason is null) return;
Log.Debug($"listen: source ended {reason}");
- Ui.BeginInvoke(() => _ = StopListening());
+ Dispatch.BeginInvoke(() => _ = StopListening());
};
Listen.Start(source);
ShowNotes();
@@ -141,8 +214,34 @@ sealed class Controller
public async Task StopListening()
{
+ var id = Listen.SessionId;
await Listen.Stop();
Changed();
+ if (id is not null) _ = TellWhenNotesReady(id);
+ }
+
+ /// The final notes take a few seconds after 结束; say so once they're written.
+ async Task TellWhenNotesReady(string id)
+ {
+ for (int i = 0; i < 120; i++)
+ {
+ await Task.Delay(1000);
+ var s = Store.Get(id);
+ if (s is null || Listen.SessionId == id && Listen.Listening) return;
+ if (s.Notes is { Final: true, IsEmpty: false })
+ {
+ Dispatch.Invoke(() => Toast(L("纪要整理好了"), LF("%@ · 点这里打开", SessionStore.DisplayTitle(s)), () => ShowRecords(id)));
+ return;
+ }
+ }
+ }
+
+ /// The panel was closed while listening: the first time, say that listening goes on.
+ public void CollapsedWhileListening()
+ {
+ if (!Listen.Listening || Settings.ToldStillListening) return;
+ Settings.ToldStillListening = true; Settings.Save();
+ Toast(L("知了还在听"), L("点任务栏右下角的知了图标再打开纪要。"), ShowNotes);
}
/// The onboarding sample: heard straight from the file (Cicada's own sound is left out of
@@ -170,9 +269,13 @@ sealed class Controller
notesWindow.Refresh();
}
- public void ShowRecords()
+ public void ShowRecords() => ShowRecords(null);
+
+ public void ShowRecords(string? id)
{
- if (mainWindow is null) { mainWindow = new MainWindow(this); mainWindow.Closed += (_, _) => mainWindow = null; }
+ if (mainWindow is null) { mainWindow = new MainWindow(this, id); mainWindow.Closed += (_, _) => mainWindow = null; }
+ else if (id is not null) mainWindow.Select(id);
+ if (mainWindow.WindowState == WindowState.Minimized) mainWindow.WindowState = WindowState.Normal;
mainWindow.Show();
mainWindow.Activate();
}
@@ -194,12 +297,30 @@ sealed class Controller
}
public void CaptureSettingChanged() => notesWindow?.ApplyCaptureSetting();
+
+ public void SetShowInCapture(bool on)
+ {
+ Settings.ShowInCapture = on;
+ Settings.Save();
+ CaptureSettingChanged();
+ Changed();
+ }
+
+ public void SetTarget(string target)
+ {
+ Settings.Target = target;
+ Settings.Save();
+ Changed();
+ }
+
+ public bool HotkeyRegistered => hotkey?.Registered ?? false;
public void SettingsChanged() => Changed();
public async Task Quit()
{
if (Listen.Listening) await StopListening();
Store.Flush();
+ hotkey?.Dispose();
tray.Visible = false;
tray.Dispose();
application.Shutdown();
@@ -214,13 +335,15 @@ sealed class Controller
["pending"] = Listen.Pending,
["spoken"] = Listen.Spoken,
["target"] = Listen.Target,
- ["problem"] = Listen.Problem,
+ ["problem"] = Listen.Problem?.ToString(),
["notes"] = Notes.Status.ToString(),
["topics"] = Notes.Notes.Topics.Count,
["key"] = Ling.KeyState.ToString(),
["view"] = Settings.View,
["showInCapture"] = Settings.ShowInCapture,
["sessions"] = Store.All().Count,
+ ["hotkey"] = HotkeyRegistered,
+ ["autostart"] = AutoStart.Enabled,
};
}
@@ -271,8 +394,15 @@ static class DebugServer
case "view": app.SetView(arg == "subtitles" ? "subtitles" : "notes"); break;
case "capture": app.Settings.ShowInCapture = arg == "on"; app.Settings.Save(); app.CaptureSettingChanged(); break;
case "show":
- if (arg == "records") app.ShowRecords(); else if (arg == "settings") app.ShowSettings(); else app.ShowNotes();
+ if (arg == "records") app.ShowRecords();
+ 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 app.ShowNotes();
break;
+ case "toast": app.Toast(L("纪要整理好了"), LF("%@ · 点这里打开", "Test"), () => app.ShowRecords()); break;
+ case "problem": app.Listen.SimulateProblem(arg); break;
case "quit": _ = app.Quit(); break;
case "state": break;
default: return new JsonObject { ["error"] = $"unknown command {parts[0]}" };
diff --git a/windows/src/Cicada/Dialogs.cs b/windows/src/Cicada/Dialogs.cs
new file mode 100644
index 0000000..4129400
--- /dev/null
+++ b/windows/src/Cicada/Dialogs.cs
@@ -0,0 +1,69 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using static Cicada.Strings;
+
+namespace Cicada.App;
+
+/// Windows 11 ContentDialogs: a title, a line or a field, and two equal buttons on a grey band,
+/// primary first. Enter takes the primary button, Esc cancels.
+static class Dialogs
+{
+ /// Asks before something that can't be undone. True when the user agreed.
+ public static bool Confirm(Window owner, string title, string body, string ok, bool danger)
+ {
+ var text = Ui.Text(body, 14, Palette.Body);
+ return Show(owner, title, text, ok, danger, null) is not null;
+ }
+
+ /// A one-line answer: the new text (maybe empty), or null when cancelled.
+ public static string? Prompt(Window owner, string title, string value, string? hint, string ok)
+ {
+ var box = new TextBox { Text = value, FontSize = 14, MinHeight = 32, VerticalContentAlignment = VerticalAlignment.Center };
+ System.Windows.Automation.AutomationProperties.SetName(box, title);
+ var content = new StackPanel { Children = { box } };
+ if (hint is not null) { var h = Ui.Helper(hint); h.Margin = new Thickness(0, 8, 0, 0); content.Children.Add(h); }
+ return Show(owner, title, content, ok, danger: false, box);
+ }
+
+ static string? Show(Window owner, string title, FrameworkElement content, string ok, bool danger, TextBox? field)
+ {
+ string? result = null;
+ var dialog = new Window
+ {
+ Owner = owner, WindowStyle = WindowStyle.None, AllowsTransparency = true, Background = Brushes.Transparent,
+ ResizeMode = ResizeMode.NoResize, ShowInTaskbar = false, SizeToContent = SizeToContent.Height, Width = 456 + 32,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner, FontFamily = Palette.Font, Title = title,
+ };
+ void Accept() { result = field?.Text.Trim() ?? ""; dialog.Close(); }
+ var primary = Ui.Button(ok, Accept, danger ? Ui.Kind.Danger : Ui.Kind.Primary);
+ var cancel = Ui.Button(L("取消"), dialog.Close);
+ primary.IsDefault = true; cancel.IsCancel = true;
+ var buttons = new Grid();
+ buttons.ColumnDefinitions.Add(new ColumnDefinition());
+ buttons.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });
+ buttons.ColumnDefinitions.Add(new ColumnDefinition());
+ Grid.SetColumn(cancel, 2);
+ buttons.Children.Add(primary); buttons.Children.Add(cancel);
+ var heading = Ui.Text(title, 20, Palette.Ink, FontWeights.SemiBold);
+ content.Margin = new Thickness(0, 12, 0, 0);
+ dialog.Content = new Border
+ {
+ Margin = new Thickness(16), Background = Palette.Surface, BorderBrush = Palette.ControlStroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8),
+ Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 32, ShadowDepth = 8, Opacity = 0.25 },
+ Child = new StackPanel
+ {
+ Children =
+ {
+ new Border { Padding = new Thickness(24, 24, 24, 24), Child = new StackPanel { Children = { heading, content } } },
+ new Border { Background = Palette.Mica, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(0, 1, 0, 0), CornerRadius = new CornerRadius(0, 0, 8, 8), Padding = new Thickness(24, 20, 24, 20), Child = buttons },
+ },
+ },
+ };
+ dialog.MouseLeftButtonDown += (_, e) => { if (e.ButtonState == MouseButtonState.Pressed) try { dialog.DragMove(); } catch { } };
+ dialog.Loaded += (_, _) => { if (field is not null) { field.Focus(); field.SelectAll(); } else primary.Focus(); };
+ dialog.ShowDialog();
+ return result;
+ }
+}
diff --git a/windows/src/Cicada/MainWindow.cs b/windows/src/Cicada/MainWindow.cs
index bf0bcce..0084513 100644
--- a/windows/src/Cicada/MainWindow.cs
+++ b/windows/src/Cicada/MainWindow.cs
@@ -1,77 +1,87 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using System.Windows.Threading;
using static Cicada.Strings;
namespace Cicada.App;
-/// 会议记录: the meetings on the left, the chosen one's notes and bilingual transcript on the
-/// right, on one white sheet (no cards), as the Mac's main window.
+/// How a meeting is described in lists: "10:03 · 23 分钟 · 待办 2".
+static class Records
+{
+ public static string Meta(Session s, Controller app)
+ {
+ if (app.Listen.Listening && app.Listen.SessionId == s.Id) return L("正在听");
+ var local = s.StartedAt.ToLocalTime();
+ var day = local.Date == DateTime.Today || local.Date == DateTime.Today.AddDays(-1)
+ ? local.ToString("HH:mm", Culture)
+ : local.ToString(L("M月d日"), Culture);
+ var parts = new List<string> { day, LF("%@ 分钟", Math.Max(1, (int)Math.Round(s.Duration.TotalMinutes))) };
+ if (s.Notes?.Todos.Count is > 0 and var n) parts.Add(LF("待办 %@", n));
+ return string.Join(" · ", parts);
+ }
+
+ public static string Group(Session s)
+ {
+ var d = s.StartedAt.ToLocalTime().Date;
+ return d == DateTime.Today ? L("今天") : d == DateTime.Today.AddDays(-1) ? 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.
sealed class MainWindow : Window
{
readonly Controller app;
- readonly ListBox list = new() { BorderThickness = new Thickness(0), Background = Brushes.Transparent, FontFamily = Palette.Font };
+ readonly TextBox search = new() { FontSize = 14, MinHeight = 34, VerticalContentAlignment = VerticalAlignment.Center, Padding = new Thickness(30, 0, 8, 0) };
+ readonly StackPanel list = new();
readonly ContentControl detail = new();
string? selected;
+ string tab = "notes";
+ double? jumpTo;
+ string? shownKey;
bool refreshQueued;
- /// A record row: grey ground when selected, a lighter one under the mouse; no Windows blue.
- static readonly Style RowStyle = MakeRowStyle();
-
- static Style MakeRowStyle()
- {
- var template = new ControlTemplate(typeof(ListBoxItem));
- var border = new FrameworkElementFactory(typeof(Border), "bg");
- border.SetValue(Border.CornerRadiusProperty, new CornerRadius(8));
- border.SetValue(Border.BackgroundProperty, Brushes.Transparent);
- border.SetValue(Border.MarginProperty, new Thickness(0, 0, 0, 2));
- border.AppendChild(new FrameworkElementFactory(typeof(ContentPresenter)));
- template.VisualTree = border;
- var hover = new Trigger { Property = UIElement.IsMouseOverProperty, Value = true };
- hover.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Ground, "bg"));
- var chosen = new Trigger { Property = ListBoxItem.IsSelectedProperty, Value = true };
- chosen.Setters.Add(new Setter(Border.BackgroundProperty, Palette.Line, "bg"));
- template.Triggers.Add(hover); template.Triggers.Add(chosen);
- var style = new Style(typeof(ListBoxItem));
- style.Setters.Add(new Setter(Control.TemplateProperty, template));
- style.Setters.Add(new Setter(FrameworkElement.FocusVisualStyleProperty, null));
- style.Seal();
- return style;
- }
-
- public MainWindow(Controller app)
+ public MainWindow(Controller app, string? select = null)
{
this.app = app;
+ selected = select;
Title = L("会议记录") + " · " + L("知了");
- Width = 1000; Height = 680; MinWidth = 720; MinHeight = 480;
- Background = Palette.Card; FontFamily = Palette.Font; Icon = AppIcon.Image;
+ Width = 1200; Height = Math.Min(780, SystemParameters.WorkArea.Height - 24); MinWidth = 960; MinHeight = 520;
+ Background = Palette.Mica; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
var grid = new Grid();
- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(290) });
- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1) });
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(300) });
grid.ColumnDefinitions.Add(new ColumnDefinition());
- var left = new DockPanel { Margin = new Thickness(12, 16, 8, 12) };
- var top = Ui.Row(8, Ui.Heading(L("会议记录"), 17));
- top.Margin = new Thickness(8, 0, 0, 12);
- DockPanel.SetDock(top, Dock.Top);
- left.Children.Add(top);
- left.Children.Add(list);
- Grid.SetColumn(left, 0);
- var divider = new Border { Background = Palette.Line };
- Grid.SetColumn(divider, 1);
- var right = new ScrollViewer { Content = detail, Padding = new Thickness(32, 24, 32, 32), VerticalScrollBarVisibility = ScrollBarVisibility.Auto };
- Grid.SetColumn(right, 2);
- grid.Children.Add(left); grid.Children.Add(divider); grid.Children.Add(right);
- Content = grid;
- list.SelectionChanged += (_, _) =>
+ // The search box, with its icon and placeholder drawn over it
+ var placeholder = Ui.Text(L("搜索标题、纪要和原话"), 14, Palette.Tertiary, 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;
+ System.Windows.Automation.AutomationProperties.SetName(search, L("搜索标题、纪要和原话"));
+ search.TextChanged += (_, _) => { placeholder.Visibility = search.Text.Length == 0 ? Visibility.Visible : Visibility.Collapsed; Fill(); };
+ var searchBox = new Grid { Margin = new Thickness(12, 8, 12, 8), Children = { search, glass, placeholder } };
+
+ var left = new DockPanel();
+ DockPanel.SetDock(searchBox, Dock.Top);
+ left.Children.Add(searchBox);
+ left.Children.Add(new ScrollViewer { Content = list, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(8, 0, 8, 12) });
+
+ var right = new Border
{
- if (list.SelectedItem is ListBoxItem { Tag: string id } && id != selected) { selected = id; ShowDetail(); }
+ Background = Palette.Surface, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(1, 1, 0, 0),
+ CornerRadius = new CornerRadius(8, 0, 0, 0), Child = detail,
};
+ Grid.SetColumn(right, 1);
+ grid.Children.Add(left); grid.Children.Add(right);
+ Content = grid;
Refresh();
}
+ public void Select(string id) { selected = id; tab = "notes"; shownKey = null; Fill(); }
+
public void Refresh()
{
if (refreshQueued) return;
@@ -79,82 +89,227 @@ sealed class MainWindow : Window
Dispatcher.BeginInvoke(() => { refreshQueued = false; Fill(); });
}
+ static bool Matches(Session s, string q) =>
+ q.Length == 0
+ || SessionStore.DisplayTitle(s).Contains(q, StringComparison.OrdinalIgnoreCase)
+ || (s.Notes?.Summary.Contains(q, StringComparison.OrdinalIgnoreCase) ?? false)
+ || s.Lines.Any(l => l.Src.Contains(q, StringComparison.OrdinalIgnoreCase) || (l.Dst?.Contains(q, StringComparison.OrdinalIgnoreCase) ?? false));
+
void Fill()
{
- var sessions = app.Store.All();
- list.Items.Clear();
- foreach (var s in sessions)
+ var all = app.Store.All();
+ var q = search.Text.Trim();
+ var shown = all.Where(s => Matches(s, q)).ToList();
+ list.Children.Clear();
+ string? group = null;
+ foreach (var s in shown)
{
- var live = app.Listen.Listening && app.Listen.SessionId == s.Id;
- var row = Ui.Stack(2,
- Ui.Text(SessionStore.DisplayTitle(s), 13, Palette.Ink, FontWeights.SemiBold, wrap: false),
- Ui.Text(live ? L("正在听") : $"{s.StartedAt.ToLocalTime():yyyy-MM-dd HH:mm} · {Languages.Clock(s.Duration.TotalSeconds)}", 11, live ? Palette.Accent : Palette.Tertiary, wrap: false));
- row.Margin = new Thickness(6, 6, 6, 6);
- list.Items.Add(new ListBoxItem { Content = row, Tag = s.Id, Style = RowStyle });
+ var g = Records.Group(s);
+ 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);
+ list.Children.Add(h);
+ }
+ list.Children.Add(Item(s));
}
- if (sessions.Count == 0) { selected = null; detail.Content = Empty(); return; }
- selected ??= sessions[0].Id;
- if (sessions.All(s => s.Id != selected)) selected = sessions[0].Id;
- list.SelectedItem = list.Items.Cast<ListBoxItem>().First(i => (string)i.Tag == selected);
+ if (all.Count == 0) { selected = null; detail.Content = Empty(L("还没有会议记录"), L("点任务栏里的知了图标,开始听第一场会。")); return; }
+ if (shown.Count == 0) { detail.Content = Empty(L("没有找到"), ""); return; }
+ if (selected is null || shown.All(s => s.Id != selected)) selected = shown[0].Id;
+ foreach (var child in list.Children.OfType<Button>()) Paint(child);
+ // Store changes come in a burst while a meeting runs; redraw the open page only if it changed.
+ var key = app.Store.Get(selected!) is { } cur ? $"{selected}|{SessionStore.DisplayTitle(cur)}|{cur.Lines.Count}|{cur.Notes?.Covered}|{cur.Notes?.Final}|{app.Listen.Listening}" : null;
+ if (key == shownKey) return;
+ shownKey = key;
ShowDetail();
}
- static FrameworkElement Empty() => Ui.Stack(6, Ui.Heading(L("还没有会议记录")), Ui.Helper(L("点“开始听”,电脑里播放的声音会变成双语字幕和纪要")));
+ Button Item(Session s)
+ {
+ 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),
+ 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)),
+ };
+ b.Template = RowTemplate();
+ b.Click += (_, _) => { selected = s.Id; tab = "notes"; foreach (var child in list.Children.OfType<Button>()) Paint(child); ShowDetail(); };
+ System.Windows.Automation.AutomationProperties.SetName(b, SessionStore.DisplayTitle(s));
+ return b;
+ }
+
+ void Paint(Button b)
+ {
+ var on = (string)b.Tag == selected;
+ b.Background = on ? Palette.Surface : Brushes.Transparent;
+ b.Effect = on ? new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 3, ShadowDepth = 1, Opacity = 0.08 } : null;
+ }
+
+ /// A list row: white and raised when chosen, a grey wash under the mouse otherwise.
+ static ControlTemplate RowTemplate()
+ {
+ var t = new ControlTemplate(typeof(Button));
+ var border = new FrameworkElementFactory(typeof(Border), "bg");
+ border.SetValue(Border.CornerRadiusProperty, new CornerRadius(6));
+ border.SetBinding(Border.BackgroundProperty, new System.Windows.Data.Binding("Background") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.SetBinding(Border.PaddingProperty, new System.Windows.Data.Binding("Padding") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.AppendChild(new FrameworkElementFactory(typeof(ContentPresenter)));
+ t.VisualTree = border;
+ 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.Selected, "bg"));
+ t.Triggers.Add(hover);
+ return t;
+ }
+
+ 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);
+ 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;
+ }
void ShowDetail()
{
- if (selected is null || app.Store.Get(selected) is not { } s) { detail.Content = Empty(); return; }
- var page = new StackPanel { MaxWidth = 720, HorizontalAlignment = HorizontalAlignment.Left };
- var title = Ui.Text(SessionStore.DisplayTitle(s), 22, Palette.Ink, FontWeights.SemiBold);
- page.Children.Add(title);
- page.Children.Add(Gap(Ui.Helper($"{s.StartedAt.ToLocalTime():yyyy-MM-dd HH:mm} · {Languages.Clock(s.Duration.TotalSeconds)} · {s.Lines.Count} {L("句")}"), 4));
-
- var actions = Ui.Row(8,
- Ui.Button(L("导出"), () => Export(s)),
- Ui.Button(L("重命名"), () => Rename(s)),
- Ui.Button(L("删除"), () => Delete(s)));
- if (s.Notes is null or { IsEmpty: true } && !(app.Listen.Listening && app.Listen.SessionId == s.Id))
- actions.Children.Insert(0, Ui.Button(L("生成纪要"), () => _ = app.Notes.Generate(s.Id), "primary"));
- page.Children.Add(Gap(actions, 14));
-
- if (s.Notes is { IsEmpty: false } n)
+ 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 title = Ui.Text(SessionStore.DisplayTitle(s), 26, Palette.Ink, FontWeights.SemiBold);
+ top.Children.Add(Ui.Row(6, title, Ui.IconButton(Icons.Pencil, L("重命名"), () => Rename(s), Palette.Secondary, 32, 16)));
+ 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) };
+ var hasNotes = s.Notes is { IsEmpty: false };
+ if (!hasNotes && !live) tools.Children.Add(Ui.Button(L("生成纪要"), () => _ = app.Notes.Generate(s.Id), Ui.Kind.Primary));
+ else
{
- page.Children.Add(Gap(Ui.Heading(L("纪要"), 16), 28));
- page.Children.Add(Gap(Ui.Text(n.Summary, 14, Palette.Body), 8));
- foreach (var t in n.Topics)
+ Button? copy = null;
+ copy = Ui.Button(L("复制纪要"), () =>
{
- page.Children.Add(Gap(Ui.Row(8, Ui.Text(Languages.Clock(t.Start), 12, Palette.Link, FontWeights.SemiBold, wrap: false), Ui.Text(t.Title, 14, Palette.Ink, FontWeights.SemiBold)), 16));
- if (t.Summary.Length > 0) page.Children.Add(Gap(Ui.Text(t.Summary, 13, Palette.Secondary), 4));
- foreach (var p in t.Points) page.Children.Add(Gap(Ui.Text("· " + p, 13, Palette.Body), 4));
- }
- Section(page, L("结论"), n.Conclusions.Select(c => c.Text));
- Section(page, L("待办"), n.Todos.Select(t => "☐ " + t.Text + (t.Owner is null ? "" : $" · {t.Owner}")));
+ 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);
+ 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;
+ }
+
+ static T Spaced<T>(T e, double left) where T : FrameworkElement { e.Margin = new Thickness(left, 0, 0, 0); return e; }
- page.Children.Add(Gap(Ui.Heading(L("文字记录"), 16), 28));
+ 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 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 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))));
+
+ 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;
+ }
+
+ 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.SurfaceAlt, BorderBrush = Palette.StrokeSoft, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8), Padding = new Thickness(16, 14, 16, 14), Margin = new Thickness(0, 0, 0, 16), Child = s };
+ }
+
+ FrameworkElement Transcript(Session s, ScrollViewer scroll)
+ {
+ var body = new StackPanel { MaxWidth = 760, HorizontalAlignment = HorizontalAlignment.Left };
+ 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;
foreach (var l in s.Lines)
{
- var row = new Grid { Margin = new Thickness(0, 10, 0, 0) };
- row.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(56) });
- row.ColumnDefinitions.Add(new ColumnDefinition());
- var time = Ui.Text(Languages.Clock(l.T), 12, Palette.Link, FontWeights.SemiBold, wrap: false);
- var text = Ui.Stack(2, Ui.Text(l.Src, 14, Palette.Ink));
- if (!string.IsNullOrEmpty(l.Dst) && l.Dst != l.Src) text.Children.Add(Ui.Text(l.Dst, 13, Palette.Secondary));
- Grid.SetColumn(text, 1);
- row.Children.Add(time); row.Children.Add(text);
- page.Children.Add(row);
+ var line = NotesWindow.TranscriptRow(l);
+ if (ReferenceEquals(l, nearest)) target = line;
+ body.Children.Add(line);
+ }
+ if (target is Panel row)
+ {
+ // 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 __)
+ {
+ row.Loaded -= Jump;
+ var y = row.TransformToAncestor(body).Transform(new Point(0, 0)).Y;
+ scroll.ScrollToVerticalOffset(Math.Max(0, y - 24));
+ }
+ row.Loaded += Jump;
+ var fade = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
+ fade.Tick += (_, _) => { row.Background = Brushes.Transparent; fade.Stop(); };
+ fade.Start();
}
- detail.Content = page;
+ jumpTo = null;
+ return body;
}
static FrameworkElement Gap(FrameworkElement e, double top) { e.Margin = new Thickness(0, top, 0, 0); return e; }
- static void Section(StackPanel page, string title, IEnumerable<string> items)
+ static void Flash(Button b, string text)
{
- var list = items.ToList();
- if (list.Count == 0) return;
- page.Children.Add(Gap(Ui.Text(title, 13, Palette.Secondary, FontWeights.SemiBold), 18));
- foreach (var i in list) page.Children.Add(Gap(Ui.Text(i, 13, Palette.Body), 4));
+ var label = ((StackPanel)b.Content).Children.OfType<TextBlock>().Last();
+ var was = label.Text;
+ label.Text = text;
+ var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1.5) };
+ timer.Tick += (_, _) => { label.Text = was; timer.Stop(); };
+ timer.Start();
}
void Export(Session s)
@@ -170,20 +325,15 @@ sealed class MainWindow : Window
void Rename(Session s)
{
- var box = new TextBox { Text = SessionStore.DisplayTitle(s), FontSize = 14, Padding = new Thickness(6), MinWidth = 320 };
- var window = Ui.StyledWindow(L("重命名"), 420, 170);
- window.Owner = this;
- window.ResizeMode = ResizeMode.NoResize;
- window.Content = Ui.Card(Ui.Stack(12, box, Ui.Row(8,
- Ui.Button(L("保存"), () => { if (box.Text.Trim().Length > 0) app.Store.Rename(s.Id, box.Text); window.Close(); }, "primary"),
- Ui.Button(L("取消"), window.Close))), 16);
- window.Loaded += (_, _) => { box.Focus(); box.SelectAll(); };
- window.ShowDialog();
+ var notesTitle = s.Notes?.Title;
+ var answer = Dialogs.Prompt(this, L("重命名"), SessionStore.DisplayTitle(s), notesTitle is { Length: > 0 } ? LF("清空就用纪要起的名字:%@", notesTitle) : null, L("保存"));
+ if (answer is null) return;
+ if (answer.Length == 0) app.Store.ResetTitle(s.Id); else app.Store.Rename(s.Id, answer);
}
void Delete(Session s)
{
- var ok = MessageBox.Show(this, LF("删除“%@”?删除后无法恢复。", SessionStore.DisplayTitle(s)), L("删除"), MessageBoxButton.OKCancel, MessageBoxImage.Warning);
- if (ok == MessageBoxResult.OK) app.Store.Delete(s.Id);
+ if (Dialogs.Confirm(this, L("删除这次会议?"), LF("“%@”的纪要和文字记录都会删掉,没法恢复。", SessionStore.DisplayTitle(s)), L("删除"), danger: true))
+ app.Store.Delete(s.Id);
}
}
diff --git a/windows/src/Cicada/NotesWindow.cs b/windows/src/Cicada/NotesWindow.cs
index 1cf4f36..ccf1740 100644
--- a/windows/src/Cicada/NotesWindow.cs
+++ b/windows/src/Cicada/NotesWindow.cs
@@ -7,20 +7,25 @@ using static Cicada.Strings;
namespace Cicada.App;
-/// The window shown while listening: live notes (default) or the subtitle bar. Like the Mac's
-/// notes panel it never takes focus (the user keeps typing in their meeting app) and stays out of
-/// screen captures unless 共享屏幕时让对方看到 is on, which shows a badge.
+/// The window shown while listening: the live notes panel (default) or the subtitle bar. Like the
+/// Mac's it never takes focus (the user keeps typing in their meeting app) and stays out of screen
+/// captures unless 共享屏幕时让对方看到 is on, which it then says plainly.
sealed class NotesWindow : Window
{
readonly Controller app;
readonly DispatcherTimer clock = new() { Interval = TimeSpan.FromSeconds(1) };
- // Kept across renders: the clock only redraws the header, and the notes keep their scroll position.
- ContentControl header = new(), live = new();
+ // Hosts kept between renders: the clock redraws only the header, and the body keeps its scroll.
+ ContentControl header = new(), bars = new(), live = new(), tabs = new(), footer = new();
ScrollViewer scroll = new();
string? builtFor;
- /// Whether Windows agreed to keep the window out of captures; if not, it's shown as visible.
+ string tab = "notes";
+ /// Whether Windows agreed to keep the window out of captures; if not, it says it may be seen.
bool hiddenFromCapture;
- bool renderQueued;
+ bool renderQueued, placedSubtitles;
+ // Rebuilt only when what they show changes, so a click never lands on a button that a
+ // re-render just replaced; the clock and the countdown are text updated in place.
+ string? headerKey, tabsKey, barsKey;
+ readonly TextBlock clockText = Ui.Text("", 13, Palette.Secondary, wrap: false), dueText = Ui.Text("", 12, Palette.Tertiary, wrap: false);
public NotesWindow(Controller app)
{
@@ -39,17 +44,15 @@ sealed class NotesWindow : Window
Native.MakeNonActivating(this);
ApplyCaptureSetting();
};
- // Drag from anywhere that isn't a link, button or scroll bar (those mark the click handled).
+ // Drag from anywhere that isn't a control (buttons and links mark the press handled).
MouseLeftButtonDown += (_, e) => { if (e.ButtonState == MouseButtonState.Pressed) try { DragMove(); } catch { } };
- clock.Tick += (_, _) => header.Content = Header();
+ clock.Tick += (_, _) => Tick();
IsVisibleChanged += (_, _) => { if (IsVisible) clock.Start(); else clock.Stop(); };
- // The subtitle bar fits its text (a long line wraps to two or three) and grows upward, so its
- // bottom edge stays where it was placed or dragged.
+ // The subtitle bar fits its text and grows upward, so its bottom edge stays put.
SizeChanged += (_, e) =>
{
if (!Subtitles || !e.HeightChanged) return;
- // The first real height arrives after Place(): sit it above the taskbar then.
- if (e.PreviousSize.Height <= 0 || !placedSubtitles) { Top = SystemParameters.WorkArea.Bottom - e.NewSize.Height - 24; placedSubtitles = true; }
+ if (e.PreviousSize.Height <= 0 || !placedSubtitles) { Top = SystemParameters.WorkArea.Bottom - e.NewSize.Height - 16; placedSubtitles = true; }
else Top -= e.NewSize.Height - e.PreviousSize.Height;
};
Place();
@@ -57,24 +60,23 @@ sealed class NotesWindow : Window
}
bool Subtitles => app.Settings.View == "subtitles";
- bool placedSubtitles;
- /// Notes at the right edge, subtitles along the bottom, on the primary screen's work area.
+ /// The panel along the right edge, the subtitle bar along the bottom, on the primary work area.
public void Place()
{
var area = SystemParameters.WorkArea;
if (Subtitles)
{
- SizeToContent = SizeToContent.Height; MinHeight = 96;
- Width = Math.Min(820, area.Width - 40);
- Left = area.Left + (area.Width - Width) / 2; Top = area.Bottom - Math.Max(ActualHeight, MinHeight) - 24;
+ SizeToContent = SizeToContent.Height; MinHeight = 80; MinWidth = 480;
+ Width = Math.Min(920, area.Width - 40);
+ Left = area.Left + (area.Width - Width) / 2; Top = area.Bottom - Math.Max(ActualHeight, MinHeight) - 16;
placedSubtitles = ActualHeight > 0;
}
else
{
- SizeToContent = SizeToContent.Manual; MinHeight = 0;
- Width = 380; Height = Math.Min(620, area.Height - 48);
- Left = area.Right - Width - 20; Top = area.Top + 24;
+ SizeToContent = SizeToContent.Manual; MinHeight = 360; MinWidth = 340;
+ Width = 416; Height = Math.Min(836, area.Height - 16);
+ Left = area.Right - Width - 8; Top = area.Top + 8;
}
}
@@ -94,86 +96,177 @@ sealed class NotesWindow : Window
Dispatcher.BeginInvoke(DispatcherPriority.Background, () => { renderQueued = false; Render(); });
}
+ void Collapse()
+ {
+ Hide();
+ app.CollapsedWhileListening();
+ }
+
+ void Tick()
+ {
+ var session = app.Listen.SessionId is { } id ? app.Store.Get(id) : null;
+ clockText.Text = app.Listen.Listening && session is not null ? Languages.Clock((DateTimeOffset.Now - session.StartedAt).TotalSeconds) : "";
+ dueText.Text = Due() ?? "";
+ }
+
+ static void Detach(FrameworkElement e) { if (e.Parent is Panel p) p.Children.Remove(e); }
+
void Render()
{
var mode = Subtitles ? "subtitles" : "notes";
if (builtFor != mode)
{
- builtFor = mode;
- // New hosts for a new layout: an element can't move between parents.
- header = new ContentControl(); live = new ContentControl();
- scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Margin = new Thickness(0, 12, 0, 0) };
- FrameworkElement layout;
- if (Subtitles) layout = Ui.Stack(8, header, live);
- else
- {
- var dock = new DockPanel();
- DockPanel.SetDock(header, Dock.Top);
- var liveCard = new Border { Background = Palette.Ground, CornerRadius = new CornerRadius(10), Padding = new Thickness(12, 10, 12, 10), Child = live, Margin = new Thickness(0, 12, 0, 0) };
- DockPanel.SetDock(liveCard, Dock.Top);
- dock.Children.Add(header); dock.Children.Add(liveCard); dock.Children.Add(scroll);
- layout = dock;
- }
- Content = new Border
- {
- Background = Palette.Card, CornerRadius = new CornerRadius(14), BorderBrush = Palette.Line, BorderThickness = new Thickness(1),
- Padding = new Thickness(16, 12, 16, 14), Child = layout,
- Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 18, ShadowDepth = 2, Opacity = 0.12 },
- Margin = new Thickness(8),
- };
+ builtFor = mode; headerKey = tabsKey = barsKey = null;
+ header = new ContentControl(); bars = new ContentControl(); live = new ContentControl(); tabs = new ContentControl(); footer = new ContentControl();
+ scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Padding = new Thickness(16, 14, 12, 16) };
+ Content = Subtitles ? SubtitleFrame() : PanelFrame();
}
- header.Content = Header();
- live.Content = LiveLine(Subtitles ? 20 : 15);
- if (!Subtitles)
+ var key = $"{app.Listen.Listening}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";
+ if (key != headerKey) { headerKey = key; header.Content = Header(); }
+ Tick();
+ if (Subtitles) { live.Content = SubtitleLine(); return; }
+ var bk = $"{app.Listen.Problem}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";
+ if (bk != barsKey) { barsKey = bk; bars.Content = Bars(); }
+ live.Content = LiveCard();
+ var count = app.Listen.SessionId is { } sid ? app.Store.Get(sid)?.Lines.Count ?? 0 : 0;
+ if ($"{tab}|{count}" != tabsKey) { tabsKey = $"{tab}|{count}"; tabs.Content = TabRow(); }
+ footer.Content = Footer();
+ var atBottom = scroll.VerticalOffset >= scroll.ScrollableHeight - 4;
+ var offset = scroll.VerticalOffset;
+ scroll.Content = tab == "transcript" ? Transcript() : NotesBody();
+ // The transcript follows new lines while the reader is at its end; otherwise nothing jumps.
+ if (tab == "transcript" && atBottom) scroll.ScrollToEnd(); else scroll.ScrollToVerticalOffset(offset);
+ }
+
+ // MARK: The panel
+
+ FrameworkElement PanelFrame()
+ {
+ var dock = new DockPanel();
+ void Top(UIElement e) { DockPanel.SetDock(e, Dock.Top); dock.Children.Add(e); }
+ Top(header);
+ Top(bars);
+ Top(live);
+ tabs.Margin = new Thickness(12, 10, 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);
+ dock.Children.Add(scroll);
+ return new Border
{
- var offset = scroll.VerticalOffset;
- scroll.Content = NotesBody();
- scroll.ScrollToVerticalOffset(offset);
- }
+ Background = Palette.Surface, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8),
+ Child = dock, Margin = new Thickness(8),
+ Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 24, ShadowDepth = 4, Opacity = 0.14 },
+ };
}
FrameworkElement Header()
{
var listen = app.Listen;
var session = listen.SessionId is { } id ? app.Store.Get(id) : null;
- string status = listen.Listening && session is not null
- ? L("正在听 · ") + Languages.Clock((DateTimeOffset.Now - session.StartedAt).TotalSeconds)
- : L("知了");
- var left = Ui.Row(8, Ui.Dot(listen.Listening ? Palette.Accent : Palette.Line), Ui.Text(status, 13, Palette.Ink, FontWeights.SemiBold, wrap: false));
- // Never silently exposed: a failed exclusion gets a badge too.
- if (app.Settings.ShowInCapture) left.Children.Add(WithMargin(Ui.Badge(L("对方可见")), 8));
- else if (!hiddenFromCapture) left.Children.Add(WithMargin(Ui.Badge(L("可能被共享")), 8));
- var right = Ui.Row(12,
- Ui.LinkText(listen.Listening ? L("结束") : L("开始听"), () => _ = app.ToggleListening()),
- Ui.LinkText(Subtitles ? L("纪要") : L("字幕"), () => app.SetView(Subtitles ? "notes" : "subtitles")),
- Ui.LinkText("×", Hide));
- var grid = new DockPanel { LastChildFill = false };
- DockPanel.SetDock(left, Dock.Left); DockPanel.SetDock(right, Dock.Right);
- grid.Children.Add(left); grid.Children.Add(right);
- return grid;
- }
-
- static T WithMargin<T>(T e, double left) where T : FrameworkElement { e.Margin = new Thickness(left, 0, 0, 0); return e; }
-
- /// The newest line, translation large, original small above it; "…" while Ming is still on one.
- FrameworkElement LiveLine(double big)
+ 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.StopListening(), 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));
+ 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));
+ Detach(clockText);
+ clockText.FontSize = 13; clockText.Foreground = Palette.Secondary; clockText.HorizontalAlignment = HorizontalAlignment.Left;
+ left.Children.Add(Gap(clockText, 8));
+ }
+ else
+ {
+ left.Children.Add(AppIcon.Small(18));
+ left.Children.Add(Gap(Ui.Text(L("知了"), 14, Palette.Ink, FontWeights.SemiBold, 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.StopListening(), 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));
+ var row = Ui.Spread(left, right);
+ row.Height = 56;
+ row.Margin = new Thickness(16, 0, 8, 0);
+ return row;
+ }
+
+ /// What needs the user: Ling failing, or the window being visible to others.
+ FrameworkElement Bars()
+ {
+ var stack = new StackPanel { Margin = new Thickness(12, 0, 12, 0) };
+ void Add(FrameworkElement bar) { bar.Margin = new Thickness(0, 0, 0, 8); stack.Children.Add(bar); }
+ switch (app.Listen.Problem)
+ {
+ case LingException.Kind.Network or LingException.Kind.Timeout or LingException.Kind.Http:
+ Add(Ui.InfoBar(Ui.Severity.Error, L("连不上 Ling"), L("这段时间的话没能识别。检查网络后点重试。"),
+ Ui.Button(L("重试"), () => { app.Listen.ClearProblem(); _ = app.Ling.Check(); }, height: 32)));
+ break;
+ case LingException.Kind.RateLimited:
+ Add(Ui.InfoBar(Ui.Severity.Warning, L("Ling 太忙"), L("稍后会自动重试。")));
+ break;
+ case LingException.Kind.InvalidKey or LingException.Kind.NoKey:
+ Add(Ui.InfoBar(Ui.Severity.Error, L("Ling key 无效"), L("去设置里换一个 key。"), Ui.Button(L("打开设置"), app.ShowSettings, height: 32)));
+ break;
+ }
+ if (app.Settings.ShowInCapture)
+ Add(Ui.InfoBar(Ui.Severity.Warning, null, L("共享屏幕时,对方能看到这个窗口。"),
+ Ui.LinkText(L("改回只有我看得到"), () => app.SetShowInCapture(false))));
+ else if (!hiddenFromCapture)
+ Add(Ui.InfoBar(Ui.Severity.Warning, null, L("Windows 没能把这个窗口从屏幕共享里藏起来,对方可能看得到。")));
+ return stack;
+ }
+
+ /// The newest line: the original small, its translation large, then "在听下一句" while Ming works.
+ FrameworkElement LiveCard()
{
var listen = app.Listen;
var line = listen.SessionId is { } id ? app.Store.Get(id)?.Lines.LastOrDefault() : null;
var stack = new StackPanel();
if (line is null)
{
- var hint = listen.Problem ?? (listen.Listening ? (listen.Pending > 0 ? L("正在听…") : L("等有人说话")) : L("点“开始听”,电脑里播放的声音会变成双语字幕和纪要"));
- stack.Children.Add(Ui.Text(hint, 13, listen.Problem is null ? Palette.Tertiary : Palette.Accent));
- return stack;
+ 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));
}
- if (line.Dst is not null && line.Dst != line.Src) stack.Children.Add(Ui.Text(line.Src, 12, Palette.Secondary));
- var main = Ui.Text(line.Dst ?? line.Src, big, Palette.Ink, FontWeights.SemiBold);
- main.Margin = new Thickness(0, 2, 0, 0);
- stack.Children.Add(main);
- var foot = listen.Problem ?? (listen.Pending > 0 ? L("正在听…") : null);
- if (foot is not null) { var f = Ui.Helper(foot); f.Margin = new Thickness(0, 4, 0, 0); stack.Children.Add(f); }
- return stack;
+ else
+ {
+ stack.Children.Add(Ui.Text($"{Ui.SpokenName(line.SrcLang)} · {Languages.Clock(line.T)}", 12, Palette.Tertiary, 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));
+ }
+ // 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(8), Padding = new Thickness(14, 12, 14, 12), Margin = new Thickness(12, 0, 12, 0), Child = stack, MinHeight = 126 };
+ }
+
+ 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);
+ }
+
+ string? Due()
+ {
+ if (app.Notes.Status == NotesEngine.State.Updating && !app.Notes.Notes.IsEmpty) return L("正在整理纪要…");
+ if (app.Notes.NextUpdate is { } next && app.Listen.Listening)
+ return LF("%@ 秒后更新", Math.Max(1, (int)Math.Ceiling((next - DateTime.UtcNow).TotalSeconds)));
+ return null;
}
FrameworkElement NotesBody()
@@ -182,45 +275,169 @@ sealed class NotesWindow : Window
var body = new StackPanel();
if (notes.IsEmpty)
{
- var hint = app.Notes.Status switch
+ var (title, hint) = app.Notes.Status switch
{
- NotesEngine.State.NoKey => L("生成纪要需要 API key"),
- NotesEngine.State.InvalidKey => L("这个 key 无效,请检查是否复制完整,或重新创建一个"),
- NotesEngine.State.RateLimited => L("请求过于频繁,稍后会自动重试。"),
- NotesEngine.State.Updating => L("正在整理纪要…"),
- _ => app.Listen.Listening ? L("会中每 45 秒更新") : "",
+ NotesEngine.State.Updating => (L("正在整理纪要…"), ""),
+ NotesEngine.State.NoKey => (L("生成纪要需要 API key"), ""),
+ NotesEngine.State.InvalidKey => (L("这个 key 无效,请检查是否复制完整,或重新创建一个"), ""),
+ _ => app.Listen.Listening ? (L("纪要会在开会几分钟后出现"), L("之后每 45 秒更新一次")) : ("", ""),
};
- if (hint.Length > 0) body.Children.Add(Spaced(Ui.Helper(hint), 2));
+ 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 (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 } t) body.Children.Add(Spaced(Ui.Heading(t, 16), 4));
- if (notes.Summary.Length > 0) body.Children.Add(Spaced(Ui.Text(notes.Summary, 13, Palette.Body), 6));
+ 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)
{
- body.Children.Add(Spaced(Ui.Row(8, Ui.Text(Languages.Clock(topic.Start), 11, Palette.Link, FontWeights.SemiBold, wrap: false),
- Ui.Text(topic.Title, 13, Palette.Ink, FontWeights.SemiBold)), 14));
- foreach (var p in topic.Points) body.Children.Add(Spaced(Bullet(p), 4));
+ 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));
}
if (notes.Conclusions.Count > 0)
{
- body.Children.Add(Spaced(Ui.Text(L("结论"), 12, Palette.Secondary, FontWeights.SemiBold), 16));
- foreach (var c in notes.Conclusions) body.Children.Add(Spaced(Bullet(c.Text), 4));
+ body.Children.Add(Gap(Ui.Text(L("结论"), 13, Palette.Secondary, FontWeights.SemiBold), 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(Spaced(Ui.Text(L("待办"), 12, Palette.Secondary, FontWeights.SemiBold), 16));
- foreach (var todo in notes.Todos) body.Children.Add(Spaced(Bullet("☐ " + todo.Text + (todo.Owner is null ? "" : $" · {todo.Owner}"), bullet: false), 4));
+ body.Children.Add(Gap(Ui.Text(L("待办"), 13, Palette.Secondary, FontWeights.SemiBold), 18, top: true));
+ foreach (var todo in notes.Todos) body.Children.Add(Gap(Todo(todo), 6, top: true));
}
- if (app.Notes.Status == NotesEngine.State.Updating) body.Children.Add(Spaced(Ui.Helper(L("正在整理纪要…")), 12));
return body;
}
- static FrameworkElement Spaced(FrameworkElement e, double top) { e.Margin = new Thickness(0, top, 0, 0); return e; }
+ FrameworkElement Transcript()
+ {
+ var lines = app.Listen.SessionId is { } id ? app.Store.Get(id)?.Lines ?? [] : [];
+ var body = new StackPanel();
+ foreach (var l in lines) body.Children.Add(TranscriptRow(l));
+ return body;
+ }
+
+ internal static FrameworkElement TranscriptRow(TranscriptLine l)
+ {
+ 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();
+ 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;
+ }
+
+ 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 };
+ }
+
+ // MARK: The subtitle bar
+
+ FrameworkElement SubtitleFrame()
+ {
+ var grid = new Grid();
+ grid.ColumnDefinitions.Add(new ColumnDefinition());
+ grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
+ Grid.SetColumn(header, 1);
+ 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 new Border
+ {
+ Background = new SolidColorBrush(Color.FromArgb(0xEB, 0x15, 0x17, 0x1C)), BorderBrush = new SolidColorBrush(Color.FromArgb(0x14, 0xFF, 0xFF, 0xFF)),
+ BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(12), Padding = new Thickness(16, 6, 10, 14), Margin = new Thickness(8),
+ Child = new StackPanel { Children = { handle, grid } },
+ Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 28, ShadowDepth = 6, Opacity = 0.35 },
+ };
+ }
+
+ 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) };
+ if (line is null)
+ 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 row = new DockPanel();
+ DockPanel.SetDock(left, Dock.Left);
+ row.Children.Add(left);
+ row.Children.Add(text);
+ return row;
+ }
+
+ // MARK: Bits
+
+ static T Gap<T>(T e, double size, bool top = false) where T : FrameworkElement
+ {
+ e.Margin = top ? new Thickness(0, size, 0, 0) : new Thickness(size, 0, 0, 0);
+ return e;
+ }
+
+ static FrameworkElement Bullet(string text)
+ {
+ var dock = new DockPanel();
+ var dot = Ui.Text("·", 14, Palette.Body, wrap: false);
+ dot.Width = 12;
+ DockPanel.SetDock(dot, Dock.Left);
+ dock.Children.Add(dot);
+ dock.Children.Add(Ui.Text(text, 14, Palette.Body));
+ return dock;
+ }
- static FrameworkElement Bullet(string text, bool bullet = true)
+ /// A to-do: an empty box (notes are read-only here), the task, and who has it.
+ internal static FrameworkElement Todo(NoteItem todo)
{
- var t = Ui.Text((bullet ? "· " : "") + text, 13, Palette.Body);
- t.Margin = new Thickness(bullet ? 2 : 0, 0, 0, 0);
- return t;
+ var dock = new DockPanel();
+ var box = new Border { Width = 16, Height = 16, BorderBrush = Palette.Secondary, BorderThickness = new Thickness(1.5), CornerRadius = new CornerRadius(3), Margin = new Thickness(0, 2, 10, 0), VerticalAlignment = VerticalAlignment.Top };
+ DockPanel.SetDock(box, Dock.Left);
+ dock.Children.Add(box);
+ var text = new TextBlock { TextWrapping = TextWrapping.Wrap, FontSize = 14, FontFamily = Palette.Font, Foreground = Palette.Ink };
+ text.Inlines.Add(new System.Windows.Documents.Run(todo.Text));
+ if (todo.Owner is { Length: > 0 } owner) text.Inlines.Add(new System.Windows.Documents.Run($" · {owner}") { Foreground = Palette.Secondary });
+ dock.Children.Add(text);
+ return dock;
}
}
diff --git a/windows/src/Cicada/Onboarding.cs b/windows/src/Cicada/Onboarding.cs
index 6a2f1a2..7ba4e4c 100644
--- a/windows/src/Cicada/Onboarding.cs
+++ b/windows/src/Cicada/Onboarding.cs
@@ -1,79 +1,186 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Shapes;
using System.Windows.Threading;
using static Cicada.Strings;
namespace Cicada.App;
-/// First run, three steps. Windows needs no permission for system audio, and listening needs the
-/// Ling key (recognition is Ming's), so the key comes first: Ling key → system audio → sample meeting.
+/// 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 → 系统声音 → 试一下.
sealed class Onboarding : Window
{
readonly Controller app;
- readonly ContentControl page = new();
+ readonly ContentControl stepper = new(), page = new(), footer = new();
int step;
SystemAudioTap? tap;
- readonly DispatcherTimer meter = new() { Interval = TimeSpan.FromMilliseconds(100) };
+ readonly DispatcherTimer meter = new() { Interval = TimeSpan.FromMilliseconds(80) };
+ readonly double[] levels = new double[32];
double level, peak;
+ bool autoStart = true, playing;
+ // 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 };
+ readonly ContentControl keyStatus = new();
+ bool checking;
public Onboarding(Controller app)
{
this.app = app;
- Title = L("知了");
- Width = 520; Height = 460; ResizeMode = ResizeMode.NoResize;
- Background = Palette.Ground; FontFamily = Palette.Font; Icon = AppIcon.Image;
+ Title = L("设置知了");
+ Width = 720; Height = 560; ResizeMode = ResizeMode.NoResize;
+ Background = Palette.SurfaceAlt; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
- Content = new Border { Padding = new Thickness(24), Child = page };
- meter.Tick += (_, _) => { if (step == 1) Render(); };
+ 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;
+ meter.Tick += (_, _) => { if (step == 1) Meter(); };
Closed += (_, _) => StopTap();
+ 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; };
+ keyText.TextChanged += (_, _) => { if (keyBox.Password != keyText.Text) keyBox.Password = keyText.Text; };
step = app.Ling.HasKey ? 1 : 0;
Render();
}
- void Next()
+ void Go(int to)
{
StopTap();
- step++;
- if (step > 2) { app.Settings.Onboarded = true; app.Settings.Save(); Close(); return; }
+ if (to > 2)
+ {
+ AutoStart.Enabled = autoStart;
+ app.Settings.Onboarded = true; app.Settings.Save();
+ Close();
+ app.ShowFlyout();
+ return;
+ }
+ step = Math.Max(0, to);
Render();
}
- void Render() => page.Content = step switch { 0 => KeyStep(), 1 => AudioStep(), _ => SampleStep() };
+ void Render()
+ {
+ stepper.Content = Stepper();
+ page.Content = step switch { 0 => KeyStep(), 1 => AudioStep(), _ => SampleStep() };
+ footer.Content = Footer();
+ }
- FrameworkElement Frame(string title, string helper, FrameworkElement body, FrameworkElement buttons)
+ FrameworkElement Stepper()
{
- var dots = Ui.Row(6, Enumerable.Range(0, 3).Select(i => Ui.Dot(i == step ? Palette.Accent : Palette.Line, 7)).ToArray());
- var dock = new DockPanel();
- DockPanel.SetDock(buttons, Dock.Bottom);
- buttons.HorizontalAlignment = HorizontalAlignment.Right;
- dock.Children.Add(buttons);
- dock.Children.Add(Ui.Card(Ui.Stack(12, dots, Ui.Heading(title, 18), Ui.Helper(helper), body), 24));
- return dock;
+ var row = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(40, 20, 40, 0) };
+ string[] names = [L("接上 Ling"), L("系统声音"), L("试一下")];
+ for (int i = 0; i < names.Length; i++)
+ {
+ if (i > 0) row.Children.Add(new Border { Width = 32, Height = 1, Background = Palette.ControlStroke, Margin = new Thickness(10, 0, 10, 0), VerticalAlignment = VerticalAlignment.Center });
+ var done = i < step; var now = i == step;
+ var badge = new Grid { Width = 22, Height = 22 };
+ badge.Children.Add(new Ellipse { Fill = done ? Palette.Success : now ? Palette.Ink : Brushes.Transparent, Stroke = done || now ? null : Palette.Tertiary, StrokeThickness = 1 });
+ if (done) badge.Children.Add(Ui.Icon(Icons.Check, 12, Brushes.White, stroke: 2.4));
+ else { var n = Ui.Text($"{i + 1}", 12, now ? Brushes.White : Palette.Secondary, FontWeights.SemiBold, wrap: false); n.HorizontalAlignment = HorizontalAlignment.Center; n.VerticalAlignment = VerticalAlignment.Center; badge.Children.Add(n); }
+ row.Children.Add(Ui.Row(8, badge, Ui.Text(names[i], 13, now ? Palette.Ink : Palette.Secondary, now ? FontWeights.SemiBold : FontWeights.Normal, wrap: false)));
+ }
+ return row;
+ }
+
+ FrameworkElement Page(string title, string text, params UIElement[] body)
+ {
+ var s = new StackPanel { Margin = new Thickness(40, 28, 40, 0) };
+ s.Children.Add(Ui.Text(title, 26, Palette.Ink, FontWeights.SemiBold));
+ var p = Ui.Text(text, 14, Palette.Body);
+ 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 + 18, f.Margin.Right, f.Margin.Bottom); s.Children.Add(b); }
+ return s;
}
+ FrameworkElement Footer()
+ {
+ var buttons = new StackPanel { Orientation = Orientation.Horizontal };
+ var back = Ui.Button(L("上一步"), () => Go(step - 1));
+ back.IsEnabled = step > 0;
+ buttons.Children.Add(back);
+ var next = step switch
+ {
+ 0 => Ui.Button(L("继续"), () => _ = SaveKey(), Ui.Kind.Primary),
+ 1 => Ui.Button(L("继续"), () => Go(2), peak >= 0.01 ? Ui.Kind.Primary : Ui.Kind.Standard),
+ _ => Ui.Button(L("完成"), () => Go(3), Ui.Kind.Primary),
+ };
+ next.Margin = new Thickness(8, 0, 0, 0);
+ next.IsEnabled = !checking;
+ buttons.Children.Add(next);
+ UIElement left = step == 1 ? Ui.Text(L("没有声音?先确认电脑没静音"), 13, Palette.Secondary, wrap: false) : new Border();
+ var row = Ui.Spread(left, buttons);
+ ((FrameworkElement)left).VerticalAlignment = VerticalAlignment.Center;
+ row.Margin = new Thickness(24, 18, 24, 18);
+ return new Border { Background = Palette.Subtle, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(0, 1, 0, 0), Child = row };
+ }
+
+ // MARK: 1 · Ling key
+
FrameworkElement KeyStep()
{
- var box = new PasswordBox { FontSize = 13, Padding = new Thickness(6) };
- var status = Ui.Helper("");
- async void Save()
+ var open = Ui.Button(L("打开 Ling 开放平台"), () => Process.Start(new ProcessStartInfo("https://chat.ant-ling.com/platform/api") { UseShellExecute = true }), Ui.Kind.Standard, Icons.OpenExternal);
+ open.HorizontalAlignment = HorizontalAlignment.Left;
+ var reveal = Ui.IconButton(Icons.Eye, L("显示 key"), () =>
{
- var text = box.Password.Trim();
- if (!text.StartsWith("sk-")) { status.Text = L("复制 sk- 开头的 key,回来粘贴"); return; }
- app.Key.Save(text);
- app.Ling.KeyChanged();
- status.Text = L("正在检查…");
- var (state, _) = await app.Ling.Check();
- if (state == KeyState.Ok) Next();
- else status.Text = state == KeyState.Invalid ? L("这个 key 无效,请检查是否复制完整,或重新创建一个") : L("连不上 Ling,检查网络");
- }
- var body = Ui.Stack(10,
- Ui.LinkText(L("在 Ling 开放平台创建 key"), () => Process.Start(new ProcessStartInfo("https://chat.ant-ling.com/platform/api") { UseShellExecute = true })),
- Ui.Helper(L("在 Ling 开放平台点“创建令牌”,复制以 sk- 开头的那串。")),
- box, status);
- return Frame(L("接上 Ling,用上完整的知了"), L("识别、翻译和纪要都靠它,约 1 分钟。"), body, Ui.Row(8, Ui.Button(L("继续"), Save, "primary")));
+ var show = keyText.Visibility != Visibility.Visible;
+ keyText.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
+ keyBox.Visibility = show ? Visibility.Collapsed : Visibility.Visible;
+ }, Palette.Body, 36, 16);
+ reveal.Margin = new Thickness(4, 0, 0, 0);
+ Detach(keyBox); Detach(keyText); Detach(keyStatus);
+ var field = new Grid { Children = { keyBox, keyText } };
+ var paste = Ui.Button(L("粘贴"), () =>
+ {
+ try { if (Clipboard.ContainsText()) keyText.Text = Clipboard.GetText().Trim(); } catch { }
+ _ = SaveKey();
+ });
+ var row = new DockPanel();
+ DockPanel.SetDock(paste, Dock.Right);
+ DockPanel.SetDock(reveal, Dock.Right);
+ paste.Margin = new Thickness(4, 0, 0, 0);
+ row.Children.Add(paste); row.Children.Add(reveal); row.Children.Add(field);
+ var keyLabel = Ui.Text(L("Ling key"), 14, Palette.Ink, FontWeights.SemiBold);
+ 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, 16, Palette.Secondary), Ui.Text(L("只加密存在这台电脑上,只发给 Ling"), 13, Palette.Secondary));
+ return Page(L("接上 Ling"), L("识别、翻译和纪要都靠它。到 Ling 开放平台点“创建令牌”,复制 sk- 开头的那串,粘贴到下面。"),
+ open, Ui.Stack(6, keyLabel, row, keyStatus), privacy);
}
+ 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));
+ }
+
+ async Task SaveKey()
+ {
+ var text = keyBox.Password.Trim();
+ if (text.Length == 0 && app.Ling.HasKey) { Go(1); return; }
+ if (!text.StartsWith("sk-")) { Status(false, L("要粘贴 sk- 开头的那串")); return; }
+ checking = true; footer.Content = Footer();
+ Status(null, L("正在检查…"));
+ app.Key.Save(text);
+ 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); }
+ else Status(false, state == KeyState.Invalid ? L("这个 key 不能用,检查是否复制完整,或重新创建一个") : L("连不上 Ling,检查网络"));
+ }
+
+ // MARK: 2 · System audio
+
+ readonly ContentControl meterHost = new(), heardHost = new();
+
FrameworkElement AudioStep()
{
if (tap is null)
@@ -89,21 +196,60 @@ sealed class Onboarding : Window
tap.Start();
meter.Start();
}
- var bar = new ProgressBar { Minimum = 0, Maximum = 1, Value = Loudness(level), Height = 8, Foreground = Palette.Accent, Background = Palette.Ground, BorderThickness = new Thickness(0) };
+ Detach(meterHost); Detach(heardHost);
+ Meter();
+ var card = Ui.Card(Ui.Stack(14, Ui.Row(14, Ui.Icon(Icons.Speaker, 22, Palette.Body), meterHost), heardHost), new Thickness(20, 18, 20, 18));
+ var lines = new StackPanel();
+ if (AudioDevice.DefaultName() is { } device) lines.Children.Add(Ui.Text(LF("正在听:%@", device), 13, Palette.Secondary));
+ lines.Children.Add(Ui.Text(L("换成耳机或蓝牙音箱也能接着听。"), 13, Palette.Secondary));
+ return Page(L("系统声音"), L("知了听的是电脑播放出来的声音,不用麦克风,也不用授权。放一段视频或音乐试试。"), card, lines);
+ }
+
+ /// 32 bars of the last few seconds of loudness, newest on the right.
+ void Meter()
+ {
+ Array.Copy(levels, 1, levels, 0, levels.Length - 1);
+ levels[^1] = Loudness(level);
+ var bars = new StackPanel { Orientation = Orientation.Horizontal, Height = 40 };
+ foreach (var v in levels)
+ bars.Children.Add(new Rectangle { Width = 12, Height = 6 + v * 34, RadiusX = 2, RadiusY = 2, Margin = new Thickness(0, 0, 3, 0), VerticalAlignment = VerticalAlignment.Center, Fill = v > 0.08 ? Palette.Live : Palette.Stroke });
+ System.Windows.Automation.AutomationProperties.SetName(bars, L("系统声音"));
+ meterHost.Content = bars;
var heard = peak >= 0.01;
- var body = Ui.Stack(12, bar, Ui.Text(heard ? L("听到了") : L("放一段视频或音乐,看这条有没有跳动"), 13, heard ? Palette.Ink : Palette.Secondary));
- return Frame(L("系统声音"), L("知了听的是电脑播放出来的声音,不用麦克风,也不用授权。"), body,
- Ui.Row(8, Ui.Button(L("继续"), Next, heard ? "primary" : "quiet")));
+ var was = heardHost.Tag as bool?;
+ if (was != 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);
+ footer.Content = Footer();
+ }
}
/// -50 dBFS (a quiet room) to 0 dBFS on a log scale, so speech sits mid-bar instead of pinning it.
static double Loudness(double rms) => rms <= 0 ? 0 : Math.Clamp((20 * Math.Log10(rms) + 50) / 50, 0, 1);
+ // MARK: 3 · Try it
+
FrameworkElement SampleStep()
{
- var body = Ui.Stack(10, Ui.Text(L("播放一段约 9 秒的示例会议,看字幕和纪要怎么出现。"), 13, Palette.Secondary));
- return Frame(L("示例会议"), L("纪要窗口不会抢走焦点,也不会出现在屏幕共享里。"), body,
- Ui.Row(8, Ui.Button(L("播放示例"), () => _ = app.PlaySample(), "accent"), Ui.Button(L("完成"), Next, "primary")));
+ var play = Ui.Button(playing ? L("正在播放…") : L("播放示例"), () => _ = PlaySample(), Ui.Kind.Accent, Icons.Play, 52, iconFill: true);
+ play.IsEnabled = !playing;
+ play.HorizontalAlignment = HorizontalAlignment.Left;
+ var startup = new CheckBox { IsChecked = autoStart, Content = Ui.Text(L("开机时启动知了(在任务栏右下角待命)"), 14, Palette.Ink) };
+ startup.Click += (_, _) => autoStart = startup.IsChecked == true;
+ var howto = Ui.Text(LF("开会时点任务栏里的知了图标,或按 %@ 开始。", Hotkey.Label), 13, Palette.Secondary);
+ howto.Margin = new Thickness(28, 6, 0, 0);
+ return Page(L("试一下"), L("放一段 9 秒的英文示例会议,看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。"),
+ play, new StackPanel { Children = { startup, howto } });
+ }
+
+ async Task PlaySample()
+ {
+ playing = true; Render();
+ try { await app.PlaySample(); }
+ finally { playing = false; if (IsLoaded) Render(); }
}
void StopTap()
diff --git a/windows/src/Cicada/Platform.cs b/windows/src/Cicada/Platform.cs
new file mode 100644
index 0000000..e53e822
--- /dev/null
+++ b/windows/src/Cicada/Platform.cs
@@ -0,0 +1,119 @@
+using System.Runtime.InteropServices;
+using System.Windows.Interop;
+using Microsoft.Win32;
+
+namespace Cicada.App;
+
+/// Ctrl+Alt+L anywhere: start or end listening. A message-only window receives WM_HOTKEY.
+sealed class Hotkey : IDisposable
+{
+ public const string Label = "Ctrl+Alt+L";
+ const int Id = 0xC1CA, WmHotkey = 0x0312;
+ const uint ModAlt = 0x1, ModControl = 0x2, ModNoRepeat = 0x4000, VkL = 0x4C;
+ readonly HwndSource source;
+ readonly Action pressed;
+ /// False when another app already holds the combination (Settings says so).
+ public bool Registered { get; }
+
+ public Hotkey(Action pressed)
+ {
+ this.pressed = pressed;
+ source = new HwndSource(new HwndSourceParameters("CicadaHotkey") { ParentWindow = new IntPtr(-3) /* HWND_MESSAGE */, Width = 0, Height = 0 });
+ source.AddHook(Hook);
+ Registered = RegisterHotKey(source.Handle, Id, ModControl | ModAlt | ModNoRepeat, VkL);
+ Log.Debug($"hotkey: {(Registered ? "registered" : "taken")} {Label}");
+ }
+
+ IntPtr Hook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == WmHotkey && wParam.ToInt32() == Id) { handled = true; pressed(); }
+ return IntPtr.Zero;
+ }
+
+ public void Dispose()
+ {
+ if (Registered) UnregisterHotKey(source.Handle, Id);
+ source.Dispose();
+ }
+
+ [DllImport("user32.dll")] static extern bool RegisterHotKey(IntPtr hwnd, int id, uint modifiers, uint vk);
+ [DllImport("user32.dll")] static extern bool UnregisterHotKey(IntPtr hwnd, int id);
+}
+
+/// 开机时启动知了: the per-user Run key, so no admin rights. The dev build has its own entry.
+static class AutoStart
+{
+ const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Run";
+ static string Name => Paths.Dev ? "Cicada Dev" : "Cicada";
+ static string Command => $"\"{Environment.ProcessPath}\"" + (Paths.Dev ? " --dev" : "");
+
+ public static bool Enabled
+ {
+ get
+ {
+ try { using var k = Registry.CurrentUser.OpenSubKey(RunKey); return k?.GetValue(Name) is string; }
+ catch { return false; }
+ }
+ set
+ {
+ try
+ {
+ using var k = Registry.CurrentUser.CreateSubKey(RunKey);
+ if (value) k.SetValue(Name, Command); else k.DeleteValue(Name, throwOnMissingValue: false);
+ Log.Debug($"autostart: {(value ? "on" : "off")}");
+ }
+ catch (Exception e) { Log.Debug($"autostart: failed {e.GetType().Name}"); }
+ }
+ }
+}
+
+/// The default playback device's name ("扬声器 (Realtek High Definition Audio)") for onboarding.
+static class AudioDevice
+{
+ public static string? DefaultName()
+ {
+ try
+ {
+ var enumerator = (IMMDeviceEnumerator)new MMDeviceEnumerator();
+ Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(0 /* eRender */, 1 /* eMultimedia */, out var device));
+ Marshal.ThrowExceptionForHR(device.OpenPropertyStore(0 /* STGM_READ */, out var store));
+ var key = new PropertyKey { fmtid = new Guid("a45c254e-df1c-4efd-8020-67d146a850e0"), pid = 14 }; // PKEY_Device_FriendlyName
+ Marshal.ThrowExceptionForHR(store.GetValue(ref key, out var value));
+ var name = value.vt == 31 /* VT_LPWSTR */ ? Marshal.PtrToStringUni(value.pointer) : null;
+ PropVariantClear(ref value);
+ return name;
+ }
+ catch (Exception e) { Log.Debug($"audio device: name unavailable {e.GetType().Name}"); return null; }
+ }
+
+ [ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumerator { }
+
+ [ComImport, Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IMMDeviceEnumerator
+ {
+ [PreserveSig] int EnumAudioEndpoints(int dataFlow, int stateMask, out IntPtr devices);
+ [PreserveSig] int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice device);
+ }
+
+ [ComImport, Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IMMDevice
+ {
+ [PreserveSig] int Activate(ref Guid iid, int clsCtx, IntPtr activationParams, [MarshalAs(UnmanagedType.IUnknown)] out object iface);
+ [PreserveSig] int OpenPropertyStore(int access, out IPropertyStore store);
+ }
+
+ [ComImport, Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IPropertyStore
+ {
+ [PreserveSig] int GetCount(out int count);
+ [PreserveSig] int GetAt(int index, out PropertyKey key);
+ [PreserveSig] int GetValue(ref PropertyKey key, out PropVariant value);
+ }
+
+ [StructLayout(LayoutKind.Sequential)] struct PropertyKey { public Guid fmtid; public int pid; }
+
+ [StructLayout(LayoutKind.Explicit, Size = 24)]
+ struct PropVariant { [FieldOffset(0)] public ushort vt; [FieldOffset(8)] public IntPtr pointer; }
+
+ [DllImport("ole32.dll")] static extern int PropVariantClear(ref PropVariant value);
+}
diff --git a/windows/src/Cicada/SettingsWindow.cs b/windows/src/Cicada/SettingsWindow.cs
index e1786b4..e93d92e 100644
--- a/windows/src/Cicada/SettingsWindow.cs
+++ b/windows/src/Cicada/SettingsWindow.cs
@@ -1,117 +1,211 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Media;
using static Cicada.Strings;
namespace Cicada.App;
-/// 设置: the Ling key, languages, how listening shows, and the model.
+/// 设置, laid out as Windows 11 Settings: categories on the left, one card per setting with its
+/// control on the right, switches for on/off.
sealed class SettingsWindow : Window
{
readonly Controller app;
- readonly TextBlock keyStatus = Ui.Text("", 13, Palette.Secondary);
- readonly PasswordBox keyBox = new() { FontSize = 13, Padding = new Thickness(6), MinWidth = 280 };
+ 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 Dictionary<string, FrameworkElement> sections = [];
+ readonly PasswordBox keyBox = new() { FontSize = 14, MinHeight = 32, Width = 300, VerticalContentAlignment = VerticalAlignment.Center };
+ bool editingKey;
+ string current = "ling";
public SettingsWindow(Controller app)
{
this.app = app;
Title = L("设置") + " · " + L("知了");
- Width = 560; Height = 640; Background = Palette.Ground; FontFamily = Palette.Font; Icon = AppIcon.Image;
+ Width = 1000; Height = Math.Min(760, SystemParameters.WorkArea.Height - 24); MinWidth = 760; MinHeight = 480;
+ Background = Palette.Mica; FontFamily = Palette.Font; Icon = AppIcon.Image;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
- var s = app.Settings;
-
- var key = Ui.Card(Ui.Stack(10,
- Ui.Heading(L("Ling key")),
- keyStatus,
- Ui.Row(8, keyBox, Ui.Button(L("保存"), SaveKey, "primary")),
- Ui.Row(16, Ui.LinkText(L("获取 Ling key ↗"), OpenLing), Ui.LinkText(L("删除 key"), RemoveKey)),
- Ui.Helper(L("只存在这台电脑上(只有你的 Windows 账户能读),只发给 Ling(ant-ling.com)"))));
-
- var languages = Ui.Card(Ui.Stack(12,
- Ui.Heading(L("语言")),
- Field(L("翻译成"), Ui.Choice(Ui.TargetOptions(), s.Target, v => { s.Target = v; Save(); })),
- Field(L("纪要语言"), Ui.Choice([("system", L("和字幕一样")), .. Languages.Targets.Select(t => (t.Code, t.Name))], s.NotesLanguage, v => { s.NotesLanguage = v; Save(); })),
- Field(L("界面语言"), Ui.Choice([("system", L("跟随系统")), ("zh-Hans", "简体中文"), ("en", "English"), ("ja", "日本語"), ("ko", "한국어")], s.UiLanguage,
- v => { s.UiLanguage = v; Save(); MessageBox.Show(this, L("重新打开知了后生效"), L("知了")); }))));
-
- var capture = new CheckBox { Content = Ui.Text(L("共享屏幕时让对方看到"), 13), IsChecked = s.ShowInCapture, FocusVisualStyle = null };
- capture.Click += (_, _) => { s.ShowInCapture = capture.IsChecked == true; Save(); app.CaptureSettingChanged(); };
- var display = Ui.Card(Ui.Stack(12,
- Ui.Heading(L("显示")),
- Field(L("听的时候显示"), Ui.Choice([("notes", L("实时纪要")), ("subtitles", L("字幕条"))], s.View, v => app.SetView(v))),
- capture,
- Ui.Helper(L("关着时,截图和屏幕共享里看不到纪要窗口和字幕"))));
+ 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());
+ Grid.SetColumn(scroll, 1);
+ grid.Children.Add(nav); grid.Children.Add(scroll);
+ Content = grid;
+ app.Ling.Changed += OnLingChanged;
+ Closed += (_, _) => app.Ling.Changed -= OnLingChanged;
+ Render();
+ }
- var model = Ui.Card(Ui.Stack(12,
- Ui.Heading(L("模型")),
- Field(L("纪要和翻译"), Ui.Choice([("Ling-3.1-flash", "Ling-3.1-flash"), ("Ling-3.0-flash", "Ling-3.0-flash")], s.Model,
- v => { s.Model = v; app.Ling.Model = v; Save(); })),
- Ui.Helper(L("3.1 更准;3.0 更快、更省")),
- Ui.Helper(L("语音识别用 Ming(云端),一次请求同时返回原文和译文"))));
+ void OnLingChanged() => Dispatcher.BeginInvoke(Render);
- var about = Ui.Card(Ui.Stack(8,
- Ui.Heading(L("关于")),
- Ui.Helper($"{L("知了")} {typeof(SettingsWindow).Assembly.GetName().Version?.ToString(3)} · Windows"),
- Ui.Row(16, Ui.LinkText(L("打开记录所在文件夹"), () => OpenFolder(Paths.Sessions)), Ui.LinkText(L("打开日志"), () => OpenFolder(Path.GetDirectoryName(Paths.Log)!)))));
+ void Render()
+ {
+ var offset = scroll.VerticalOffset;
+ sections.Clear();
+ var page = new StackPanel { MaxWidth = 860, HorizontalAlignment = HorizontalAlignment.Stretch };
+ var title = Ui.Text(L("设置"), 28, Palette.Ink, FontWeights.SemiBold);
+ title.Margin = new Thickness(0, 4, 0, 8);
+ page.Children.Add(title);
+ 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(
+ Card(Icons.Globe, L("翻译成"), null, Ui.Choice(Ui.TargetOptions(), app.Settings.Target, app.SetTarget)),
+ Card(null, L("纪要语言"), null, Ui.Choice([("system", L("和字幕一样")), .. Languages.Targets.Select(t => (t.Code, t.Name))], app.Settings.NotesLanguage, v => { app.Settings.NotesLanguage = v; Save(); })),
+ Card(null, L("界面语言"), L("重新打开知了后生效"), Ui.Choice([("system", L("跟随系统")), ("zh-Hans", "简体中文"), ("en", "English"), ("ja", "日本語"), ("ko", "한국어")], app.Settings.UiLanguage, v => { app.Settings.UiLanguage = v; Save(); }))));
+ var size = new Slider { Minimum = 18, Maximum = 32, Value = app.Settings.SubtitleSize, Width = 200, IsSnapToTickEnabled = true, TickFrequency = 1, VerticalAlignment = VerticalAlignment.Center };
+ System.Windows.Automation.AutomationProperties.SetName(size, L("字幕文字大小"));
+ size.ValueChanged += (_, e) => { app.Settings.SubtitleSize = (int)e.NewValue; Save(); };
+ Section(page, "listen", L("听的时候"), Group(
+ 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, "privacy", L("隐私与启动"), Group(
+ Card(Icons.Eye, L("共享屏幕时让对方看到"), L("关着时,截图和屏幕共享里看不到纪要和字幕"), Ui.Switch(app.Settings.ShowInCapture, app.SetShowInCapture, L("共享屏幕时让对方看到"))),
+ Card(Icons.Power, L("开机时启动知了"), null, Ui.Switch(AutoStart.Enabled, v => AutoStart.Enabled = v, L("开机时启动知了"))),
+ Card(Icons.Folder, L("会议记录存放位置"), $"{Paths.Sessions} · {L("和 Mac 版格式相同")}", Ui.Button(L("打开文件夹"), () => OpenFolder(Paths.Sessions), height: 32))));
+ var version = typeof(SettingsWindow).Assembly.GetName().Version?.ToString(3) ?? "";
+ Section(page, "about", L("关于"), Group(Card(null, LF("知了 %@", version), null, Ui.LinkText(L("打开日志"), () => OpenFolder(Path.GetDirectoryName(Paths.Log)!)), AppIcon.Small(24))));
+ scroll.Content = page;
+ scroll.ScrollToVerticalOffset(offset);
+ Nav();
+ }
- Content = new ScrollViewer
+ void Nav()
+ {
+ nav.Children.Clear();
+ (string id, string icon, string label)[] items =
+ [
+ ("ling", Icons.Key, L("Ling")), ("lang", Icons.Globe, L("语言")), ("listen", Icons.Wave, L("听的时候")),
+ ("privacy", Icons.Shield, L("隐私与启动")), ("about", Icons.Info, L("关于")),
+ ];
+ foreach (var (id, icon, label) in items)
{
- Content = Ui.Stack(12, key, languages, display, model, about),
- Padding = new Thickness(20), VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- };
- app.Ling.Changed += OnLingChanged;
- Closed += (_, _) => app.Ling.Changed -= OnLingChanged;
- ShowKeyState();
+ var on = id == current;
+ var content = new Grid();
+ var mark = new Border { Width = 3, Height = 16, CornerRadius = new CornerRadius(2), Background = on ? Palette.Ink : Brushes.Transparent, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(-12, 0, 0, 0) };
+ content.Children.Add(mark);
+ 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.Selected : 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);
+ };
+ System.Windows.Automation.AutomationProperties.SetName(b, label);
+ nav.Children.Add(b);
+ }
}
- static FrameworkElement Field(string label, FrameworkElement control)
+ static ControlTemplate NavTemplate()
{
- var g = new Grid();
- g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(140) });
- g.ColumnDefinitions.Add(new ColumnDefinition());
- var t = Ui.Text(label, 13, Palette.Secondary);
- t.VerticalAlignment = VerticalAlignment.Center;
- Grid.SetColumn(control, 1);
- control.HorizontalAlignment = HorizontalAlignment.Left;
- g.Children.Add(t); g.Children.Add(control);
- return g;
+ var t = new ControlTemplate(typeof(Button));
+ var border = new FrameworkElementFactory(typeof(Border), "bg");
+ border.SetValue(Border.CornerRadiusProperty, new CornerRadius(6));
+ border.SetBinding(Border.BackgroundProperty, new System.Windows.Data.Binding("Background") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.SetBinding(Border.PaddingProperty, new System.Windows.Data.Binding("Padding") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ var content = new FrameworkElementFactory(typeof(ContentPresenter));
+ content.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
+ border.AppendChild(content);
+ t.VisualTree = border;
+ 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.Subtle, "bg"));
+ t.Triggers.Add(hover);
+ return t;
}
- void Save() { app.Settings.Save(); app.SettingsChanged(); }
+ void Section(StackPanel page, string id, string title, params FrameworkElement[] groups)
+ {
+ var h = Ui.Text(title, 14, Palette.Ink, FontWeights.SemiBold);
+ h.Margin = new Thickness(0, 20, 0, 8);
+ sections[id] = h;
+ page.Children.Add(h);
+ foreach (var g in groups) { g.Margin = new Thickness(0, 0, 0, 6); page.Children.Add(g); }
+ }
+
+ /// Cards that belong together share one border, 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.Stroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(6), Child = s };
+ }
- void OnLingChanged() => Dispatcher.BeginInvoke(ShowKeyState);
+ /// 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);
+ control.VerticalAlignment = VerticalAlignment.Center;
+ control.Margin = new Thickness(16, 0, 0, 0);
+ DockPanel.SetDock(control, Dock.Right);
+ dock.Children.Add(control);
+ var text = new StackPanel { VerticalAlignment = VerticalAlignment.Center };
+ text.Children.Add(Ui.Text(title, 14, Palette.Ink));
+ if (description is not null) { var d = Ui.Helper(description); d.Margin = new Thickness(0, 2, 0, 0); text.Children.Add(d); }
+ dock.Children.Add(text);
+ return dock;
+ }
- void ShowKeyState()
+ FrameworkElement KeyCard()
{
+ var state = app.Ling.KeyState;
var key = app.Key.Read();
- keyStatus.Text = app.Ling.KeyState switch
+ string desc = state switch
{
- KeyState.None => L("还没填 API key"),
+ KeyState.None => L("还没填 key"),
KeyState.Checking => L("正在检查…"),
- KeyState.Invalid => L("这个 key 无效,请检查是否复制完整,或重新创建一个"),
+ KeyState.Invalid => L("这个 key 不能用,检查是否复制完整,或重新创建一个"),
KeyState.Unreachable => L("连不上 Ling,检查网络"),
- KeyState.Ok => AIKey.Masked(key ?? "") + " · " + L("可以用"),
- _ => AIKey.Masked(key ?? ""),
+ _ => $"{AIKey.Masked(key ?? "")} · {L("可以用 · 只加密存在这台电脑上")}",
};
+ FrameworkElement control;
+ if (editingKey)
+ {
+ if (keyBox.Parent is Panel p) p.Children.Remove(keyBox);
+ control = Ui.Row(8, keyBox, Ui.Button(L("保存"), () => _ = SaveKey(), Ui.Kind.Primary, height: 32), Ui.Button(L("取消"), () => { editingKey = false; Render(); }, height: 32));
+ }
+ else
+ {
+ var change = Ui.Button(key is null ? L("填写") : L("更换"), () => { editingKey = true; keyBox.Clear(); Render(); keyBox.Focus(); }, height: 32);
+ control = key is null ? change : Ui.Row(8, change, Ui.Button(L("删除"), () => { app.Key.Remove(); app.Ling.KeyChanged(); }, height: 32));
+ }
+ var card = Card(Icons.Key, L("Ling key"), desc, control);
+ return Group(card);
}
- async void SaveKey()
+ async Task SaveKey()
{
var text = keyBox.Password.Trim();
- if (!text.StartsWith("sk-")) { keyStatus.Text = L("复制 sk- 开头的 key,回来粘贴"); return; }
- if (!app.Key.Save(text)) { keyStatus.Text = L("保存失败"); return; }
- keyBox.Clear();
+ if (!text.StartsWith("sk-")) return;
+ if (!app.Key.Save(text)) return;
+ editingKey = false;
app.Ling.KeyChanged();
+ Render();
await app.Ling.Check();
}
- void RemoveKey()
+ static FrameworkElement Keys(string combo)
{
- app.Key.Remove();
- app.Ling.KeyChanged();
+ 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;
}
- static void OpenLing() => Process.Start(new ProcessStartInfo("https://chat.ant-ling.com/platform/api") { UseShellExecute = true });
+ void Save() { app.Settings.Save(); app.SettingsChanged(); }
static void OpenFolder(string path)
{
diff --git a/windows/src/Cicada/Strings/en.lproj/Windows.strings b/windows/src/Cicada/Strings/en.lproj/Windows.strings
index c377637..fefa498 100644
--- a/windows/src/Cicada/Strings/en.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/en.lproj/Windows.strings
@@ -1,42 +1,99 @@
-/* Windows-only UI text; the Mac's Localizable.strings covers the rest. Check: windows/scripts/strings.py */
-"显示纪要" = "Show notes";
-"还没有会议记录" = "No meetings yet";
-"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "Click “Start listening” and what your PC plays becomes bilingual subtitles and notes";
-"句" = "lines";
-"重命名" = "Rename";
-"删除“%@”?删除后无法恢复。" = "Delete “%@”? This can't be undone.";
-"对方可见" = "Visible to others";
-"等有人说话" = "Waiting for someone to speak";
-"请求过于频繁,稍后会自动重试。" = "Too many requests; retrying shortly.";
-"连不上 Ling,检查网络" = "Can't reach Ling; check your network";
-"识别、翻译和纪要都靠它,约 1 分钟。" = "Recognition, translation and notes all run on it. About a minute.";
-"听到了" = "Heard it";
-"放一段视频或音乐,看这条有没有跳动" = "Play a video or some music and watch this bar move";
-"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。" = "Cicada listens to what your PC plays. No microphone, no permission needed.";
-"播放一段约 9 秒的示例会议,看字幕和纪要怎么出现。" = "Play a 9-second sample meeting and watch the subtitles and notes appear.";
-"示例会议" = "Sample meeting";
-"纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "The notes window never takes focus and stays out of screen sharing.";
-"播放示例" = "Play sample";
+/* Windows-only UI text, over the Mac's Localizable.strings. Chinese is the key. */
+"%@ · 点这里打开" = "%@ · Select to open";
+"%@ 分钟" = "%@ min";
+"%@ 句" = "%@ lines";
+"%@ 秒后更新" = "Updates in %@s";
+"3.1 更准;3.0 更快、更省。语音识别固定用 Ming。" = "3.1 is more accurate; 3.0 is faster and costs less. Transcription always uses Ming.";
+"Ling" = "Ling";
"Ling key" = "Ling key";
-"删除 key" = "Remove key";
-"只存在这台电脑上(只有你的 Windows 账户能读),只发给 Ling(ant-ling.com)" = "Stored only on this PC (readable only by your Windows account) and sent only to Ling (ant-ling.com)";
-"和字幕一样" = "Same as subtitles";
-"界面语言" = "App language";
-"重新打开知了后生效" = "Takes effect after reopening Cicada";
-"关着时,截图和屏幕共享里看不到纪要窗口和字幕" = "When off, the notes window and subtitles don't appear in screenshots or screen sharing";
-"纪要和翻译" = "Notes and translation";
-"语音识别用 Ming(云端),一次请求同时返回原文和译文" = "Speech recognition uses Ming (cloud): one request returns both the original and the translation";
-"关于" = "About";
-"打开记录所在文件夹" = "Open the records folder";
-"可以用" = "Works";
-"保存失败" = "Couldn't save";
-"需要 Ling key 才能听" = "Listening needs a Ling key";
-"Ling key 无效" = "The Ling key is invalid";
-"Ling 太忙,稍后再试" = "Ling is busy; trying again shortly";
-"会议" = "Meeting";
-"M月d日 HH:mm" = "MMM d HH:mm";
+"Ling key 无效" = "Invalid Ling key";
+"Ling 太忙" = "Ling is busy";
"M月d日" = "MMM d";
+"M月d日 HH:mm" = "MMM d HH:mm";
+"Windows 没能把这个窗口从屏幕共享里藏起来,对方可能看得到。" = "Windows couldn't hide this window from screen sharing. Others might see it.";
"yyyy年M月d日" = "MMM d, yyyy";
+"“%@”的纪要和文字记录都会删掉,没法恢复。" = "The notes and transcript for \"%@\" will be permanently deleted.";
+"之后每 45 秒更新一次" = "Updated every 45 seconds after that";
+"会议" = "Meeting";
+"会议记录存放位置" = "Meeting records folder";
+"共享屏幕时,对方能看到这个窗口。" = "Others can see this window when you share your screen.";
+"关" = "Off";
+"关于" = "About";
+"关着时,截图和屏幕共享里看不到纪要和字幕" = "When off, notes and subtitles are hidden from screenshots and screen sharing";
+"删除这次会议?" = "Delete this meeting?";
+"去设置里换一个 key。" = "Replace your key in Settings.";
+"只加密存在这台电脑上,只发给 Ling" = "Encrypted on this PC and sent only to Ling";
+"可以用" = "Key works";
+"可以用 · 只加密存在这台电脑上" = "Working · Encrypted on this PC only";
+"听到了" = "Audio detected";
+"听电脑播放的声音,不用麦克风" = "Listens to your PC's audio, not your mic";
+"听的时候" = "While listening";
+"和 Mac 版格式相同" = "Uses the same format as Cicada for Mac";
+"和字幕一样" = "Same as subtitles";
+"在任何程序里都能按" = "Works in any app";
+"在听下一句" = "Listening for next line";
+"填写" = "Add";
+"字幕文字大小" = "Subtitle text size";
+"对方可见" = "Visible to others";
+"就绪 · Ling 已连接" = "Ready · Connected to Ling";
+"屏幕共享里看不到" = "Hidden from screen sharing";
+"开" = "On";
+"开会时点任务栏里的知了图标,或按 %@ 开始。" = "When a meeting starts, select the Cicada icon in the taskbar or press %@.";
+"开始或结束" = "Start or stop listening";
+"开机时启动知了" = "Start Cicada when I sign in";
+"开机时启动知了(在任务栏右下角待命)" = "Start Cicada when I sign in (waits in the system tray)";
+"待办 %@" = "Action items: %@";
+"打开文件夹" = "Open folder";
+"打开设置" = "Settings";
+"换成字幕条" = "Switch to subtitle bar";
+"换成纪要" = "Switch to notes";
+"换成耳机或蓝牙音箱也能接着听。" = "Keeps working when you switch to headphones or Bluetooth speakers.";
+"接上 Ling" = "Connect Ling";
+"搜索标题、纪要和原话" = "Search titles, notes, and transcripts";
+"播放示例" = "Play sample";
+"收起(继续听)" = "Hide (keep listening)";
+"改回只有我看得到" = "Hide from others";
+"放一段 9 秒的英文示例会议,看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "Play a 9-second sample meeting in English to see live subtitles and notes in action. The notes window never steals focus and stays hidden from screen sharing.";
+"显示 key" = "Show key";
+"显示纪要" = "Show notes";
+"更早" = "Earlier";
+"最近的会议" = "Recent meetings";
+"术语" = "Terms";
+"查看全部" = "See all";
+"查看记录" = "Meeting records";
+"正在听:%@" = "Listening to: %@";
+"没有声音?先确认电脑没静音" = "No sound? Make sure your PC isn't muted.";
+"没有找到" = "No results found";
+"清空就用纪要起的名字:%@" = "Leave blank to use the title from notes: %@";
+"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "Select \"Start listening\" to turn your PC's audio into live bilingual subtitles and meeting notes.";
+"点任务栏右下角的知了图标再打开纪要。" = "Select the Cicada icon in the system tray to reopen notes.";
+"点任务栏里的知了图标,开始听第一场会。" = "Select the Cicada icon in the taskbar to start your first meeting.";
+"电脑里一有人声,字幕就出来" = "Subtitles will appear as soon as someone speaks";
+"界面语言" = "App language";
+"知了 %@" = "Cicada %@";
+"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。放一段视频或音乐试试。" = "Cicada listens to what your PC plays—no mic or permissions needed. Play a video or song to test it.";
+"知了还在听" = "Cicada is still listening";
+"知了需要 Windows 10 2004 或更新的版本。" = "Cicada requires Windows 10 version 2004 or later.";
+"稍后会自动重试。" = "We'll try again automatically in a moment.";
+"等有人说话" = "Waiting for speech";
+"系统声音" = "System audio";
+"纪要会在开会几分钟后出现" = "Notes will appear a few minutes into the meeting";
"纪要停留在 %@。" = "Notes stop at %@.";
-"知了需要 Windows 10 2004 或更新的版本。" = "Cicada needs Windows 10 version 2004 or later.";
-"可能被共享" = "May be visible";
+"纪要和翻译用的模型" = "Model for notes and translation";
+"纪要整理好了" = "Meeting notes are ready";
+"要粘贴 sk- 开头的那串" = "Paste a key that starts with sk-";
+"设置知了" = "Set up Cicada";
+"识别、翻译和纪要都靠它。到 Ling 开放平台点“创建令牌”,复制 sk- 开头的那串,粘贴到下面。" = "Cicada uses Ling for transcription, translation, and notes. Go to the Ling platform, select \"Create token\", and paste the key starting with sk- below.";
+"试一下" = "Try it out";
+"还没听到声音" = "No audio detected yet";
+"还没填 key" = "No key added";
+"还没接上 Ling" = "Not connected to Ling";
+"还没有会议记录" = "No meeting records yet";
+"这个 key 不能用,检查是否复制完整,或重新创建一个" = "This key didn't work. Make sure you copied the whole key, or create a new one.";
+"这个快捷键被别的程序占用了" = "This shortcut is already in use by another app";
+"这段时间的话没能识别。检查网络后点重试。" = "Some audio couldn't be transcribed. Check your network and try again.";
+"连不上 Ling" = "Can't connect to Ling";
+"连不上 Ling,检查网络" = "Can't connect to Ling. Check your network.";
+"重命名" = "Rename";
+"重新打开知了后生效" = "Takes effect after you restart Cicada";
+"隐私与启动" = "Privacy & startup";
diff --git a/windows/src/Cicada/Strings/ja.lproj/Windows.strings b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
index f72b649..61d45b3 100644
--- a/windows/src/Cicada/Strings/ja.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
@@ -1,42 +1,99 @@
-/* Windows-only UI text; the Mac's Localizable.strings covers the rest. Check: windows/scripts/strings.py */
-"显示纪要" = "メモを表示";
-"还没有会议记录" = "まだ会議の記録はありません";
-"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "「聞き取り開始」を押すと、PC で再生される音声が 2 言語の字幕とメモになります";
-"句" = "件";
-"重命名" = "名前を変更";
-"删除“%@”?删除后无法恢复。" = "「%@」を削除しますか?元に戻せません。";
-"对方可见" = "相手に表示中";
-"等有人说话" = "誰かが話すのを待っています";
-"请求过于频繁,稍后会自动重试。" = "リクエストが多すぎます。まもなく自動で再試行します。";
-"连不上 Ling,检查网络" = "Ling に接続できません。ネットワークを確認してください";
-"识别、翻译和纪要都靠它,约 1 分钟。" = "認識・翻訳・メモはすべてこれで動きます。約 1 分。";
-"听到了" = "聞こえました";
-"放一段视频或音乐,看这条有没有跳动" = "動画や音楽を再生して、このバーが動くか確認してください";
-"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。" = "知了は PC で再生される音声を聞きます。マイクも許可も不要です。";
-"播放一段约 9 秒的示例会议,看字幕和纪要怎么出现。" = "約 9 秒のサンプル会議を再生して、字幕とメモが出る様子を見てみましょう。";
-"示例会议" = "サンプル会議";
-"纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "メモウィンドウはフォーカスを奪わず、画面共有にも映りません。";
-"播放示例" = "サンプルを再生";
+/* Windows-only UI text, over the Mac's Localizable.strings. Chinese is the key. */
+"%@ · 点这里打开" = "%@ · クリックして開く";
+"%@ 分钟" = "%@ 分";
+"%@ 句" = "%@ 行";
+"%@ 秒后更新" = "あと %@ 秒で更新";
+"3.1 更准;3.0 更快、更省。语音识别固定用 Ming。" = "3.1 はより正確、3.0 は高速で低コストです。音声認識には常に Ming が使われます。";
+"Ling" = "Ling";
"Ling key" = "Ling キー";
-"删除 key" = "キーを削除";
-"只存在这台电脑上(只有你的 Windows 账户能读),只发给 Ling(ant-ling.com)" = "この PC にのみ保存され(あなたの Windows アカウントだけが読めます)、Ling(ant-ling.com)にのみ送信されます";
-"和字幕一样" = "字幕と同じ";
-"界面语言" = "表示言語";
-"重新打开知了后生效" = "知了を開き直すと反映されます";
-"关着时,截图和屏幕共享里看不到纪要窗口和字幕" = "オフの間、メモウィンドウと字幕はスクリーンショットや画面共有に映りません";
-"纪要和翻译" = "メモと翻訳";
-"语音识别用 Ming(云端),一次请求同时返回原文和译文" = "音声認識は Ming(クラウド)を使い、1 回のリクエストで原文と訳文を返します";
-"关于" = "情報";
-"打开记录所在文件夹" = "記録フォルダを開く";
-"可以用" = "使用できます";
-"保存失败" = "保存できませんでした";
-"需要 Ling key 才能听" = "聞き取りには Ling キーが必要です";
"Ling key 无效" = "Ling キーが無効です";
-"Ling 太忙,稍后再试" = "Ling が混み合っています。まもなく再試行します";
-"会议" = "会議";
-"M月d日 HH:mm" = "M月d日 HH:mm";
+"Ling 太忙" = "Ling が混雑しています";
"M月d日" = "M月d日";
+"M月d日 HH:mm" = "M月d日 HH:mm";
+"Windows 没能把这个窗口从屏幕共享里藏起来,对方可能看得到。" = "Windows でこのウィンドウを画面共有から隠せませんでした。相手に見える可能性があります。";
"yyyy年M月d日" = "yyyy年M月d日";
+"“%@”的纪要和文字记录都会删掉,没法恢复。" = "「%@」のメモと文字起こしが削除されます。元に戻すことはできません。";
+"之后每 45 秒更新一次" = "その後は 45 秒ごとに更新されます";
+"会议" = "会議";
+"会议记录存放位置" = "会議の記録の保存先";
+"共享屏幕时,对方能看到这个窗口。" = "画面共有中、このウィンドウは相手にも見えています。";
+"关" = "オフ";
+"关于" = "情報";
+"关着时,截图和屏幕共享里看不到纪要和字幕" = "オフのときは、スクリーンショットや画面共有にメモと字幕が映りません";
+"删除这次会议?" = "この会議を削除しますか?";
+"去设置里换一个 key。" = "設定で別のキーに変更してください。";
+"只加密存在这台电脑上,只发给 Ling" = "暗号化してこの PC にのみ保存され、Ling 以外に送信されません";
+"可以用" = "使用できます";
+"可以用 · 只加密存在这台电脑上" = "使用可能 · 暗号化してこの PC にのみ保存";
+"听到了" = "音声を確認できました";
+"听电脑播放的声音,不用麦克风" = "マイクではなく、PC で再生中の音声を聞き取ります";
+"听的时候" = "聞き取り中";
+"和 Mac 版格式相同" = "Mac 版と同じ形式です";
+"和字幕一样" = "字幕と同じ";
+"在任何程序里都能按" = "どのアプリを使っていても押せます";
+"在听下一句" = "次の文を聞き取り中";
+"填写" = "入力";
+"字幕文字大小" = "字幕の文字サイズ";
+"对方可见" = "相手に表示中";
+"就绪 · Ling 已连接" = "準備完了 · Ling 接続済み";
+"屏幕共享里看不到" = "画面共有には映りません";
+"开" = "オン";
+"开会时点任务栏里的知了图标,或按 %@ 开始。" = "会議が始まったら、タスクバーの Cicada アイコンをクリックするか、%@ キーを押して開始します。";
+"开始或结束" = "聞き取りの開始 / 終了";
+"开机时启动知了" = "PC 起動時に Cicada を起動する";
+"开机时启动知了(在任务栏右下角待命)" = "PC 起動時に Cicada を起動する(タスクバー右下に常駐)";
+"待办 %@" = "ToDo %@";
+"打开文件夹" = "フォルダーを開く";
+"打开设置" = "設定";
+"换成字幕条" = "字幕バーに切り替え";
+"换成纪要" = "メモに切り替え";
+"换成耳机或蓝牙音箱也能接着听。" = "イヤホンや Bluetooth スピーカーに切り替えてもそのまま聞き取れます。";
+"接上 Ling" = "Ling に接続";
+"搜索标题、纪要和原话" = "タイトル、メモ、文字起こしを検索";
+"播放示例" = "サンプルを再生";
+"收起(继续听)" = "閉じる(聞き取りは継続)";
+"改回只有我看得到" = "自分にだけ見えるように戻す";
+"放一段 9 秒的英文示例会议,看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "9 秒間の英語のサンプル会議を再生して、字幕とメモがどのように表示されるか見てみましょう。メモウィンドウはフォーカスを奪わず、画面共有にも映りません。";
+"显示 key" = "キーを表示";
+"显示纪要" = "メモを表示";
+"更早" = "それ以前";
+"最近的会议" = "最近の会議";
+"术语" = "用語";
+"查看全部" = "すべて表示";
+"查看记录" = "会議の記録";
+"正在听:%@" = "聞き取り中:%@";
+"没有声音?先确认电脑没静音" = "音が聞こえない場合は、PC がミュートになっていないか確認してください";
+"没有找到" = "見つかりませんでした";
+"清空就用纪要起的名字:%@" = "空欄にするとメモのタイトルが使われます:%@";
+"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "「聞き取り開始」をクリックすると、PC で再生中の音声が 2 か国語の字幕とメモになります。";
+"点任务栏右下角的知了图标再打开纪要。" = "タスクバー右下の Cicada アイコンをクリックすると、メモを再度開けます。";
+"点任务栏里的知了图标,开始听第一场会。" = "タスクバーの Cicada アイコンをクリックして、最初の会議を聞き取りましょう。";
+"电脑里一有人声,字幕就出来" = "声が聞こえるとすぐに字幕が表示されます";
+"界面语言" = "表示言語";
+"知了 %@" = "Cicada %@";
+"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。放一段视频或音乐试试。" = "Cicada は PC で再生される音声を聞き取ります。マイクも権限の許可も不要です。動画や音楽を再生して試してみましょう。";
+"知了还在听" = "Cicada は聞き取りを続けています";
+"知了需要 Windows 10 2004 或更新的版本。" = "Cicada には Windows 10 バージョン 2004 以降が必要です。";
+"稍后会自动重试。" = "しばらくすると自動的に再試行します。";
+"等有人说话" = "音声を待っています";
+"系统声音" = "システム音声";
+"纪要会在开会几分钟后出现" = "メモは開始から数分後に表示されます";
"纪要停留在 %@。" = "メモは %@ までです。";
-"知了需要 Windows 10 2004 或更新的版本。" = "知了には Windows 10 バージョン 2004 以降が必要です。";
-"可能被共享" = "共有に映る可能性";
+"纪要和翻译用的模型" = "メモと翻訳に使用するモデル";
+"纪要整理好了" = "メモがまとまりました";
+"要粘贴 sk- 开头的那串" = "sk- で始まる文字列を貼り付けてください";
+"设置知了" = "Cicada のセットアップ";
+"识别、翻译和纪要都靠它。到 Ling 开放平台点“创建令牌”,复制 sk- 开头的那串,粘贴到下面。" = "音声認識、翻訳、メモの作成には Ling を使用します。Ling プラットフォームで「トークンを作成」をクリックし、sk- で始まる文字列を下に貼り付けてください。";
+"试一下" = "試してみる";
+"还没听到声音" = "まだ音声が聞こえません";
+"还没填 key" = "キーが未入力です";
+"还没接上 Ling" = "Ling に未接続";
+"还没有会议记录" = "会議の記録はまだありません";
+"这个 key 不能用,检查是否复制完整,或重新创建一个" = "このキーは使用できません。最後までコピーされているか確認するか、新しく作成してください。";
+"这个快捷键被别的程序占用了" = "このショートカットは他のアプリで使用されています";
+"这段时间的话没能识别。检查网络后点重试。" = "この間の音声を認識できませんでした。ネットワークを確認して再試行してください。";
+"连不上 Ling" = "Ling に接続できません";
+"连不上 Ling,检查网络" = "Ling に接続できません。ネットワークを確認してください。";
+"重命名" = "名前を変更";
+"重新打开知了后生效" = "Cicada の再起動後に反映されます";
+"隐私与启动" = "プライバシーと起動";
diff --git a/windows/src/Cicada/Strings/ko.lproj/Windows.strings b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
index 86c3938..b3d89af 100644
--- a/windows/src/Cicada/Strings/ko.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
@@ -1,42 +1,99 @@
-/* Windows-only UI text; the Mac's Localizable.strings covers the rest. Check: windows/scripts/strings.py */
-"显示纪要" = "노트 보기";
-"还没有会议记录" = "아직 회의 기록이 없습니다";
-"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "‘듣기 시작’을 누르면 PC에서 재생되는 소리가 이중 언어 자막과 노트가 됩니다";
-"句" = "줄";
-"重命名" = "이름 바꾸기";
-"删除“%@”?删除后无法恢复。" = "‘%@’을(를) 삭제할까요? 되돌릴 수 없습니다.";
-"对方可见" = "상대에게 보임";
-"等有人说话" = "누군가 말하기를 기다리는 중";
-"请求过于频繁,稍后会自动重试。" = "요청이 너무 많습니다. 잠시 후 자동으로 다시 시도합니다.";
-"连不上 Ling,检查网络" = "Ling에 연결할 수 없습니다. 네트워크를 확인하세요";
-"识别、翻译和纪要都靠它,约 1 分钟。" = "인식, 번역, 노트 모두 이것으로 동작합니다. 약 1분.";
-"听到了" = "들립니다";
-"放一段视频或音乐,看这条有没有跳动" = "동영상이나 음악을 재생하고 이 막대가 움직이는지 보세요";
-"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。" = "Cicada는 PC에서 재생되는 소리를 듣습니다. 마이크도 권한도 필요 없습니다.";
-"播放一段约 9 秒的示例会议,看字幕和纪要怎么出现。" = "약 9초짜리 샘플 회의를 재생해 자막과 노트가 나타나는 모습을 보세요.";
-"示例会议" = "샘플 회의";
-"纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "노트 창은 포커스를 가져가지 않고 화면 공유에도 나오지 않습니다.";
-"播放示例" = "샘플 재생";
+/* Windows-only UI text, over the Mac's Localizable.strings. Chinese is the key. */
+"%@ · 点这里打开" = "%@ · 클릭하여 열기";
+"%@ 分钟" = "%@분";
+"%@ 句" = "%@문장";
+"%@ 秒后更新" = "%@초 후 업데이트";
+"3.1 更准;3.0 更快、更省。语音识别固定用 Ming。" = "3.1은 더 정확하고, 3.0은 더 빠르고 경제적입니다. 음성 인식은 항상 Ming을 사용합니다.";
+"Ling" = "Ling";
"Ling key" = "Ling 키";
-"删除 key" = "키 삭제";
-"只存在这台电脑上(只有你的 Windows 账户能读),只发给 Ling(ant-ling.com)" = "이 PC에만 저장되며(내 Windows 계정만 읽을 수 있음) Ling(ant-ling.com)에만 전송됩니다";
-"和字幕一样" = "자막과 같게";
-"界面语言" = "앱 언어";
-"重新打开知了后生效" = "Cicada를 다시 열면 적용됩니다";
-"关着时,截图和屏幕共享里看不到纪要窗口和字幕" = "끄면 노트 창과 자막이 스크린샷과 화면 공유에 나오지 않습니다";
-"纪要和翻译" = "노트와 번역";
-"语音识别用 Ming(云端),一次请求同时返回原文和译文" = "음성 인식은 Ming(클라우드)을 쓰며, 한 번의 요청으로 원문과 번역을 함께 받습니다";
-"关于" = "정보";
-"打开记录所在文件夹" = "기록 폴더 열기";
-"可以用" = "사용 가능";
-"保存失败" = "저장하지 못했습니다";
-"需要 Ling key 才能听" = "듣기에는 Ling 키가 필요합니다";
-"Ling key 无效" = "Ling 키가 유효하지 않습니다";
-"Ling 太忙,稍后再试" = "Ling이 바쁩니다. 잠시 후 다시 시도합니다";
-"会议" = "회의";
-"M月d日 HH:mm" = "M월 d일 HH:mm";
+"Ling key 无效" = "유효하지 않은 Ling 키";
+"Ling 太忙" = "Ling 사용량 많음";
"M月d日" = "M월 d일";
+"M月d日 HH:mm" = "M월 d일 HH:mm";
+"Windows 没能把这个窗口从屏幕共享里藏起来,对方可能看得到。" = "Windows에서 이 창을 화면 공유에서 숨기지 못했습니다. 상대방에게 보일 수 있습니다.";
"yyyy年M月d日" = "yyyy년 M월 d일";
+"“%@”的纪要和文字记录都会删掉,没法恢复。" = "'%@'의 회의록과 대화 기록이 모두 삭제되며 복구할 수 없습니다.";
+"之后每 45 秒更新一次" = "이후 45초마다 업데이트됩니다";
+"会议" = "회의";
+"会议记录存放位置" = "회의 기록 저장 위치";
+"共享屏幕时,对方能看到这个窗口。" = "화면을 공유할 때 상대방이 이 창을 볼 수 있습니다.";
+"关" = "끔";
+"关于" = "정보";
+"关着时,截图和屏幕共享里看不到纪要和字幕" = "꺼 두면 스크린샷과 화면 공유에 회의록과 자막이 보이지 않습니다";
+"删除这次会议?" = "이 회의를 삭제할까요?";
+"去设置里换一个 key。" = "설정에서 다른 키로 변경하세요.";
+"只加密存在这台电脑上,只发给 Ling" = "암호화되어 이 PC에만 저장되며 Ling으로만 전송됩니다";
+"可以用" = "사용 가능";
+"可以用 · 只加密存在这台电脑上" = "사용 가능 · 암호화되어 이 PC에만 저장됨";
+"听到了" = "소리가 감지됨";
+"听电脑播放的声音,不用麦克风" = "마이크가 아닌 PC에서 재생되는 소리를 듣습니다";
+"听的时候" = "듣는 동안";
+"和 Mac 版格式相同" = "Mac 버전과 동일한 형식입니다";
+"和字幕一样" = "자막과 동일";
+"在任何程序里都能按" = "어떤 프로그램에서든 누를 수 있습니다";
+"在听下一句" = "다음 문장 듣는 중";
+"填写" = "입력";
+"字幕文字大小" = "자막 글자 크기";
+"对方可见" = "상대방에게 보임";
+"就绪 · Ling 已连接" = "준비됨 · Ling 연결됨";
+"屏幕共享里看不到" = "화면 공유에 표시되지 않음";
+"开" = "켬";
+"开会时点任务栏里的知了图标,或按 %@ 开始。" = "회의할 때 작업 표시줄의 Cicada 아이콘을 클릭하거나 %@ 키를 눌러 시작하세요.";
+"开始或结束" = "듣기 시작 또는 종료";
+"开机时启动知了" = "시작할 때 Cicada 실행";
+"开机时启动知了(在任务栏右下角待命)" = "시작할 때 Cicada 실행(작업 표시줄 오른쪽 아래에 대기)";
+"待办 %@" = "할 일 %@";
+"打开文件夹" = "폴더 열기";
+"打开设置" = "설정";
+"换成字幕条" = "자막 바로 전환";
+"换成纪要" = "회의록으로 전환";
+"换成耳机或蓝牙音箱也能接着听。" = "이어폰이나 블루투스 스피커로 바꿔도 계속 들을 수 있습니다.";
+"接上 Ling" = "Ling 연결";
+"搜索标题、纪要和原话" = "제목, 회의록, 대화 기록 검색";
+"播放示例" = "샘플 재생";
+"收起(继续听)" = "접기(계속 듣기)";
+"改回只有我看得到" = "나에게만 보이도록 변경";
+"放一段 9 秒的英文示例会议,看字幕和纪要怎么出现。纪要窗口不会抢走焦点,也不会出现在屏幕共享里。" = "9초 분량의 영어 샘플 회의를 재생해 자막과 회의록이 어떻게 나타나는지 확인해 보세요. 회의록 창은 포커스를 빼앗지 않으며 화면 공유에도 나타나지 않습니다.";
+"显示 key" = "키 표시";
+"显示纪要" = "회의록 표시";
+"更早" = "이전";
+"最近的会议" = "최근 회의";
+"术语" = "용어";
+"查看全部" = "모두 보기";
+"查看记录" = "회의 기록";
+"正在听:%@" = "듣는 중인 기기: %@";
+"没有声音?先确认电脑没静音" = "소리가 안 나나요? 먼저 PC가 음소거 상태인지 확인하세요";
+"没有找到" = "결과 없음";
+"清空就用纪要起的名字:%@" = "비워 두면 회의록에서 생성된 제목을 사용합니다: %@";
+"点“开始听”,电脑里播放的声音会变成双语字幕和纪要" = "'듣기 시작'을 클릭하면 PC에서 재생되는 소리가 실시간 이중 언어 자막과 회의록으로 변환됩니다.";
+"点任务栏右下角的知了图标再打开纪要。" = "작업 표시줄 오른쪽 아래의 Cicada 아이콘을 클릭하면 회의록을 다시 열 수 있습니다.";
+"点任务栏里的知了图标,开始听第一场会。" = "작업 표시줄의 Cicada 아이콘을 클릭해 첫 회의를 기록해 보세요.";
+"电脑里一有人声,字幕就出来" = "소리가 감지되면 바로 자막이 나타납니다";
+"界面语言" = "앱 표시 언어";
+"知了 %@" = "Cicada %@";
+"知了听的是电脑播放出来的声音,不用麦克风,也不用授权。放一段视频或音乐试试。" = "Cicada는 마이크나 별도 권한 없이 PC에서 재생되는 소리를 듣습니다. 동영상이나 음악을 재생해 테스트해 보세요.";
+"知了还在听" = "Cicada가 계속 듣고 있습니다";
+"知了需要 Windows 10 2004 或更新的版本。" = "Cicada를 사용하려면 Windows 10 버전 2004 이상이 필요합니다.";
+"稍后会自动重试。" = "잠시 후 자동으로 다시 시도합니다.";
+"等有人说话" = "음성 대기 중";
+"系统声音" = "시스템 소리";
+"纪要会在开会几分钟后出现" = "회의록은 회의 시작 몇 분 후에 나타납니다";
"纪要停留在 %@。" = "노트는 %@에서 멈춰 있습니다.";
-"知了需要 Windows 10 2004 或更新的版本。" = "Cicada에는 Windows 10 버전 2004 이상이 필요합니다.";
-"可能被共享" = "공유에 보일 수 있음";
+"纪要和翻译用的模型" = "회의록 및 번역 모델";
+"纪要整理好了" = "회의록 정리 완료";
+"要粘贴 sk- 开头的那串" = "sk-로 시작하는 키를 붙여넣어 주세요";
+"设置知了" = "Cicada 설정";
+"识别、翻译和纪要都靠它。到 Ling 开放平台点“创建令牌”,复制 sk- 开头的那串,粘贴到下面。" = "음성 인식, 번역, 회의록 작성에 모두 사용됩니다. Ling 오픈 플랫폼에서 '토큰 생성'을 클릭한 후, sk-로 시작하는 키를 복사해 아래에 붙여넣으세요.";
+"试一下" = "테스트";
+"还没听到声音" = "아직 소리가 감지되지 않음";
+"还没填 key" = "아직 키를 입력하지 않음";
+"还没接上 Ling" = "Ling에 연결되지 않음";
+"还没有会议记录" = "아직 회의 기록이 없습니다";
+"这个 key 不能用,检查是否复制完整,或重新创建一个" = "이 키는 사용할 수 없습니다. 전체를 복사했는지 확인하거나 새로 만들어 보세요.";
+"这个快捷键被别的程序占用了" = "이 단축키는 다른 프로그램에서 이미 사용 중입니다";
+"这段时间的话没能识别。检查网络后点重试。" = "이 구간의 음성을 인식하지 못했습니다. 네트워크를 확인한 후 다시 시도하세요.";
+"连不上 Ling" = "Ling에 연결할 수 없음";
+"连不上 Ling,检查网络" = "Ling에 연결할 수 없습니다. 네트워크를 확인하세요.";
+"重命名" = "이름 바꾸기";
+"重新打开知了后生效" = "Cicada를 다시 시작하면 적용됩니다";
+"隐私与启动" = "개인정보 및 시작";
diff --git a/windows/src/Cicada/TrayFlyout.cs b/windows/src/Cicada/TrayFlyout.cs
new file mode 100644
index 0000000..19afebc
--- /dev/null
+++ b/windows/src/Cicada/TrayFlyout.cs
@@ -0,0 +1,165 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Threading;
+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.
+sealed class TrayFlyout : Window
+{
+ readonly Controller app;
+ readonly ContentControl body = new();
+ readonly DispatcherTimer clock = new() { Interval = TimeSpan.FromSeconds(1) };
+ DateTime hiddenAt;
+
+ public TrayFlyout(Controller app)
+ {
+ this.app = app;
+ WindowStyle = WindowStyle.None; AllowsTransparency = true; Background = Brushes.Transparent;
+ Topmost = true; ShowInTaskbar = false; ResizeMode = ResizeMode.NoResize;
+ Width = 380 + 16; SizeToContent = SizeToContent.Height; FontFamily = Palette.Font; Title = L("知了");
+ Content = new Border
+ {
+ Margin = new Thickness(8), Background = Palette.SurfaceAlt, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8),
+ Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 28, ShadowDepth = 6, Opacity = 0.2 }, Child = body,
+ };
+ Deactivated += (_, _) => { Hide(); hiddenAt = DateTime.UtcNow; };
+ SizeChanged += (_, _) => Anchor();
+ clock.Tick += (_, _) => { if (app.Listen.Listening) Refresh(); };
+ IsVisibleChanged += (_, _) => { if (IsVisible) clock.Start(); else clock.Stop(); };
+ }
+
+ /// Opens, or closes when it is already open (a second click on the icon). A click that just
+ /// closed it by taking focus away doesn't reopen it straight away.
+ public void Toggle()
+ {
+ if (IsVisible) { Hide(); return; }
+ if ((DateTime.UtcNow - hiddenAt).TotalMilliseconds < 300) return;
+ Refresh();
+ Show();
+ Anchor();
+ Activate();
+ }
+
+ void Anchor()
+ {
+ var area = SystemParameters.WorkArea;
+ Left = area.Right - ActualWidth - 4;
+ Top = area.Bottom - ActualHeight - 4;
+ }
+
+ public void Refresh() => body.Content = Build();
+
+ FrameworkElement Build()
+ {
+ var listen = app.Listen;
+ var stack = new StackPanel();
+
+ // 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))
+ : 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);
+ stack.Children.Add(head);
+
+ // The one thing to do
+ var main = new StackPanel { Margin = new Thickness(16, 4, 16, 16) };
+ if (listen.Listening)
+ {
+ var grid = new Grid();
+ 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.StopListening(); }, Ui.Kind.Pale, Icons.Stop, 44, iconFill: true);
+ var show = Ui.Button(L("显示纪要"), () => { Hide(); app.ShowNotes(); }, Ui.Kind.Standard, Icons.Notes, 44);
+ 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($"{L("听电脑播放的声音,不用麦克风")} · {Hotkey.Label}", 12, Palette.Secondary);
+ hint.TextAlignment = TextAlignment.Center; hint.Margin = new Thickness(0, 8, 0, 0);
+ main.Children.Add(hint);
+ }
+ 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 });
+
+ // Recent meetings
+ var recent = app.Store.All().Where(s => !(listen.Listening && s.Id == listen.SessionId)).Take(3).ToList();
+ if (recent.Count > 0)
+ {
+ 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 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);
+ }
+ 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), CornerRadius = new CornerRadius(0, 0, 8, 8), Child = foot, Margin = new Thickness(0, recent.Count > 0 ? 0 : 16, 0, 0) });
+ return stack;
+ }
+
+ static FrameworkElement OptionRow(string icon, string label, FrameworkElement control, bool divider)
+ {
+ 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 };
+ }
+
+ /// A list row: no fill until the mouse is on it.
+ static ControlTemplate RowTemplate()
+ {
+ 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 });
+ var content = new FrameworkElementFactory(typeof(ContentPresenter));
+ 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"));
+ t.Triggers.Add(hover);
+ return t;
+ }
+}
diff --git a/windows/src/Cicada/Ui.cs b/windows/src/Cicada/Ui.cs
index 1e03804..eee7562 100644
--- a/windows/src/Cicada/Ui.cs
+++ b/windows/src/Cicada/Ui.cs
@@ -1,33 +1,81 @@
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Shapes;
using static Cicada.Strings;
namespace Cicada.App;
-/// The Mac's palette (Views.swift › Palette) and a few builders, so every window is made the same
-/// way in code: ground #F3F4F6, white cards, ink #15171C, one accent #E8552B for "live".
+/// Cicada's palette on Windows 11 shapes: the Mac's ground, ink and one orange for "live", plus the
+/// Fluent roles (strokes, subtle fills, info bars). Orange text and fills use darker shades of the
+/// accent so they pass 4.5:1; #E8552B itself is only for the live dot.
static class Palette
{
- static SolidColorBrush B(byte r, byte g, byte b) { var x = new SolidColorBrush(Color.FromRgb(r, g, b)); x.Freeze(); return x; }
- public static readonly SolidColorBrush Ground = B(0xF3, 0xF4, 0xF6);
- public static readonly SolidColorBrush Card = B(0xFF, 0xFF, 0xFF);
- public static readonly SolidColorBrush Ink = B(0x15, 0x17, 0x1C);
- public static readonly SolidColorBrush Body = B(0x3D, 0x41, 0x4A);
- public static readonly SolidColorBrush Secondary = B(0x5A, 0x5F, 0x6B);
- public static readonly SolidColorBrush Tertiary = B(0x6B, 0x70, 0x80);
- public static readonly SolidColorBrush Line = B(0xE4, 0xE6, 0xEA);
- public static readonly SolidColorBrush Accent = B(0xE8, 0x55, 0x2B);
- public static readonly SolidColorBrush AccentPale = B(0xFD, 0xEB, 0xE4);
- public static readonly SolidColorBrush Link = B(0xB3, 0x3B, 0x14);
- public static readonly SolidColorBrush ErrorPale = B(0xFD, 0xEC, 0xEC);
+ static SolidColorBrush B(uint rgb) { var x = new SolidColorBrush(Color.FromRgb((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb)); x.Freeze(); return x; }
+ public static readonly SolidColorBrush Mica = B(0xF3F4F6);
+ public static readonly SolidColorBrush Surface = B(0xFFFFFF);
+ public static readonly SolidColorBrush SurfaceAlt = B(0xF7F8FA);
+ public static readonly SolidColorBrush Subtle = B(0xF0F1F3);
+ public static readonly SolidColorBrush Selected = B(0xE6E8EB);
+ public static readonly SolidColorBrush Stroke = B(0xE3E5E8);
+ public static readonly SolidColorBrush StrokeSoft = B(0xEEF0F2);
+ public static readonly SolidColorBrush ControlStroke = B(0xD5D8DD);
+ public static readonly SolidColorBrush Ink = B(0x15171C);
+ public static readonly SolidColorBrush Body = B(0x3D414A);
+ public static readonly SolidColorBrush Secondary = B(0x5A5F6B);
+ public static readonly SolidColorBrush Tertiary = B(0x6B7080);
+ public static readonly SolidColorBrush Live = B(0xE8552B);
+ public static readonly SolidColorBrush AccentFill = B(0xC9441D);
+ public static readonly SolidColorBrush AccentPale = B(0xFDEBE4);
+ public static readonly SolidColorBrush AccentText = B(0xA8370F);
+ public static readonly SolidColorBrush Success = B(0x0F7B3F);
+ public static readonly SolidColorBrush Danger = B(0xC42B1C);
+ public static readonly SolidColorBrush ErrorBg = B(0xFDF0EE);
+ public static readonly SolidColorBrush ErrorStroke = B(0xF3CBC4);
+ public static readonly SolidColorBrush WarnBg = B(0xFFF6E5);
+ public static readonly SolidColorBrush WarnStroke = B(0xF1DDB0);
+ public static readonly SolidColorBrush WarnIcon = B(0x9D5D00);
+ public static readonly SolidColorBrush Night = B(0x15171C);
+ public static readonly SolidColorBrush NightText = B(0xB4B9C2);
public static readonly FontFamily Font = new("Segoe UI Variable Text, Segoe UI, Microsoft YaHei UI, Yu Gothic UI, Malgun Gothic");
}
+/// Stroke icons on a 20×20 grid (Fluent's outline style), drawn with Ui.Icon.
+static class Icons
+{
+ public const string Close = "M5,5 L15,15 M15,5 L5,15";
+ public const string Subtitles = "M4.5,4.5 H15.5 A2,2 0 0 1 17.5,6.5 V13.5 A2,2 0 0 1 15.5,15.5 H4.5 A2,2 0 0 1 2.5,13.5 V6.5 A2,2 0 0 1 4.5,4.5 Z M6,11.5 H9 M11,11.5 H14 M6,8.5 H14";
+ public const string Notes = "M5.5,2.5 H11.5 L15,6 V17.5 H5.5 Z M11.5,2.5 V6 H15 M8,10 H13 M8,13 H13";
+ public const string Stop = "M6.5,4 H13.5 A2.5,2.5 0 0 1 16,6.5 V13.5 A2.5,2.5 0 0 1 13.5,16 H6.5 A2.5,2.5 0 0 1 4,13.5 V6.5 A2.5,2.5 0 0 1 6.5,4 Z";
+ public const string Play = "M6.5,4.5 L15.5,10 L6.5,15.5 Z";
+ public const string Gear = "M12.5,10 A2.5,2.5 0 1 1 7.5,10 A2.5,2.5 0 1 1 12.5,10 Z M10,2.5 V4.5 M10,15.5 V17.5 M2.5,10 H4.5 M15.5,10 H17.5 M4.7,4.7 L6.1,6.1 M13.9,13.9 L15.3,15.3 M4.7,15.3 L6.1,13.9 M13.9,6.1 L15.3,4.7";
+ public const string Search = "M14.5,9 A5.5,5.5 0 1 1 3.5,9 A5.5,5.5 0 1 1 14.5,9 Z M13,13 L17,17";
+ public const string Export = "M10,3 V13 M6,7 L10,3 L14,7 M4,12 V16.5 H16 V12";
+ public const string Pencil = "M13.5,3.5 L16.5,6.5 L7,16 H4 V13 Z";
+ public const string Trash = "M4,6 H16 M8,6 V4 H12 V6 M5.5,6 L6.5,17 H13.5 L14.5,6";
+ public const string Copy = "M8.5,7 H14.5 A1.5,1.5 0 0 1 16,8.5 V14.5 A1.5,1.5 0 0 1 14.5,16 H8.5 A1.5,1.5 0 0 1 7,14.5 V8.5 A1.5,1.5 0 0 1 8.5,7 Z M4,13 V5.5 A1.5,1.5 0 0 1 5.5,4 H13";
+ public const string EyeOff = "M3,3 L17,17 M6.5,6.6 C4.6,7.8 3,10 3,10 C3,10 5.8,15 10,15 C11.3,15 12.5,14.6 13.5,14 M9,5.1 C9.3,5.1 9.7,5 10,5 C14.2,5 17,10 17,10 C17,10 16.4,11.1 15.3,12.3";
+ public const string Eye = "M2.5,10 C2.5,10 5.3,5 10,5 C14.7,5 17.5,10 17.5,10 C17.5,10 14.7,15 10,15 C5.3,15 2.5,10 2.5,10 Z M12.2,10 A2.2,2.2 0 1 1 7.8,10 A2.2,2.2 0 1 1 12.2,10 Z";
+ public const string Key = "M10.5,12 A3.5,3.5 0 1 1 3.5,12 A3.5,3.5 0 1 1 10.5,12 Z M9.5,9.5 L16,3 M13.5,5.5 L15.5,7.5";
+ public const string Speaker = "M3.5,8 H6.5 L10.5,4.5 V15.5 L6.5,12 H3.5 Z M13.5,7.5 A3.5,3.5 0 0 1 13.5,12.5 M15.5,5.5 A6,6 0 0 1 15.5,14.5";
+ public const string Globe = "M17,10 A7,7 0 1 1 3,10 A7,7 0 1 1 17,10 Z M3,10 H17 M10,3 C12,5 12.8,7.5 12.8,10 C12.8,12.5 12,15 10,17 C8,15 7.2,12.5 7.2,10 C7.2,7.5 8,5 10,3 Z";
+ public const string Power = "M10,3 V10 M6,5.5 A6,6 0 1 0 14,5.5";
+ public const string List = "M7,5.5 H16 M7,10 H16 M7,14.5 H16 M3.5,5.5 H4 M3.5,10 H4 M3.5,14.5 H4";
+ public const string Wave = "M3,10 H4 M6,7 V13 M9,4.5 V15.5 M12,7 V13 M15,8.5 V11.5 M17,10 H17.5";
+ public const string Shield = "M10,2.5 L16,5 V9.5 C16,13.5 13.3,16.2 10,17.5 C6.7,16.2 4,13.5 4,9.5 V5 Z";
+ public const string Folder = "M2.5,5.5 H7.5 L9,7.5 H17.5 V16 H2.5 Z";
+ public const string Keyboard = "M4,5.5 H16 A1.5,1.5 0 0 1 17.5,7 V13 A1.5,1.5 0 0 1 16,14.5 H4 A1.5,1.5 0 0 1 2.5,13 V7 A1.5,1.5 0 0 1 4,5.5 Z M5.5,8.5 H6.5 M8.5,8.5 H9.5 M11.5,8.5 H12.5 M6.5,11.5 H13.5";
+ public const string Chevron = "M6,8 L10,12 L14,8";
+ 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 OpenExternal = "M8,4 H4.5 V15.5 H16 V12 M11,3.5 H16.5 V9 M16.5,3.5 L9,11";
+}
+
static class Ui
{
- public static TextBlock Text(string text, double size = 13, Brush? color = null, FontWeight? weight = null, bool wrap = true) => new()
+ public static TextBlock Text(string text, double size = 14, Brush? color = null, FontWeight? weight = null, bool wrap = true) => new()
{
Text = text, FontSize = size, Foreground = color ?? Palette.Ink, FontWeight = weight ?? FontWeights.Normal,
TextWrapping = wrap ? TextWrapping.Wrap : TextWrapping.NoWrap, TextTrimming = wrap ? TextTrimming.None : TextTrimming.CharacterEllipsis,
@@ -35,12 +83,18 @@ static class Ui
};
public static TextBlock Heading(string text, double size = 15) => Text(text, size, Palette.Ink, FontWeights.SemiBold);
- public static TextBlock Helper(string text) => Text(text, 12, Palette.Tertiary);
+ public static TextBlock Helper(string text) => Text(text, 12, Palette.Secondary);
- public static Border Card(UIElement child, double padding = 16, double radius = 12) => new()
+ /// A 20×20 stroke icon, or a filled one, scaled to `size`.
+ public static FrameworkElement Icon(string data, double size = 16, Brush? color = null, bool fill = false, double stroke = 1.5)
{
- Background = Palette.Card, CornerRadius = new CornerRadius(radius), Padding = new Thickness(padding), Child = child,
- };
+ var path = new System.Windows.Shapes.Path { Data = Geometry.Parse(data), StrokeLineJoin = PenLineJoin.Round, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round };
+ if (fill) path.Fill = color ?? Palette.Ink;
+ else { path.Stroke = color ?? Palette.Ink; path.StrokeThickness = stroke; }
+ var canvas = new Canvas { Width = 20, Height = 20 };
+ canvas.Children.Add(path);
+ return new Viewbox { Width = size, Height = size, Child = canvas, VerticalAlignment = VerticalAlignment.Center };
+ }
public static StackPanel Stack(double gap, params UIElement[] children)
{
@@ -65,33 +119,73 @@ static class Ui
return s;
}
- /// A flat button: filled ink (primary), filled accent (live) or a quiet grey one.
- public static Button Button(string label, Action onClick, string kind = "quiet")
+ /// A row whose last child sits at the right edge: [left…] ··· [right].
+ public static DockPanel Spread(UIElement left, UIElement right)
{
- var (bg, fg) = kind switch
+ var d = new DockPanel { LastChildFill = false };
+ DockPanel.SetDock(left, Dock.Left); DockPanel.SetDock(right, Dock.Right);
+ d.Children.Add(left); d.Children.Add(right);
+ return d;
+ }
+
+ public enum Kind { Standard, Primary, Accent, Subtle, Danger, Pale }
+
+ /// Windows 11 buttons: Standard (white, hairline), Primary (ink), Accent (live orange, for
+ /// 开始听 only), Subtle (no fill until hover), Danger (red, for delete), Pale (the 结束 pill).
+ public static Button Button(string label, Action onClick, Kind kind = Kind.Standard, string? icon = null, double height = 36, bool iconFill = false)
+ {
+ var (bg, fg, border) = kind switch
{
- "primary" => (Palette.Ink, Brushes.White),
- "accent" => (Palette.Accent, Brushes.White),
- _ => (Palette.Ground, Palette.Ink),
+ Kind.Primary => (Palette.Ink, Brushes.White, Brushes.Transparent),
+ Kind.Accent => (Palette.AccentFill, Brushes.White, Brushes.Transparent),
+ Kind.Danger => (Palette.Danger, Brushes.White, Brushes.Transparent),
+ Kind.Pale => (Palette.AccentPale, Palette.AccentText, Brushes.Transparent),
+ Kind.Subtle => ((Brush)Brushes.Transparent, (Brush)Palette.Ink, (Brush)Brushes.Transparent),
+ _ => (Palette.Surface, Palette.Ink, Palette.ControlStroke),
};
+ var content = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };
+ if (icon is not null) content.Children.Add(Icon(icon, kind == Kind.Accent && height >= 48 ? 20 : 16, fg, iconFill));
+ var text = new TextBlock { Text = label, FontSize = height >= 48 ? 16 : 14, FontWeight = kind is Kind.Standard or 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);
+ content.Children.Add(text);
var b = new Button
{
- Content = new TextBlock { Text = label, FontSize = 13, FontWeight = FontWeights.SemiBold, FontFamily = Palette.Font },
- Foreground = fg, Background = bg, BorderThickness = new Thickness(0), Padding = new Thickness(14, 7, 14, 7),
- Cursor = Cursors.Hand, Focusable = false,
+ Content = content, Foreground = fg, Background = bg, BorderBrush = border, BorderThickness = new Thickness(kind == Kind.Standard ? 1 : 0),
+ Height = height, Padding = new Thickness(14, 0, 14, 0), Cursor = Cursors.Hand, MinWidth = height >= 36 ? 80 : 0,
+ // The Fluent theme left-aligns buttons; ours fill their slot unless a caller says otherwise.
+ HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Center,
};
- b.Template = RoundedTemplate(8);
+ b.Template = Template(kind is Kind.Standard or Kind.Subtle);
b.Click += (_, _) => onClick();
+ AutomationName(b, label);
return b;
}
- /// A button with rounded corners and no Windows chrome.
- static ControlTemplate RoundedTemplate(double radius)
+ /// A square icon-only button with a tooltip and an accessible name.
+ public static Button IconButton(string icon, string name, Action onClick, Brush? color = null, double size = 40, double iconSize = 16, bool fill = false, bool onDark = false)
{
- var t = new ControlTemplate(typeof(Button));
- var border = new FrameworkElementFactory(typeof(Border));
- border.SetValue(Border.CornerRadiusProperty, new CornerRadius(radius));
+ var b = new Button
+ {
+ Content = Icon(icon, iconSize, color ?? Palette.Body, fill), Width = size, Height = size, Background = Brushes.Transparent,
+ BorderThickness = new Thickness(0), Cursor = Cursors.Hand, ToolTip = name,
+ };
+ b.Template = Template(plain: true, onDark: onDark);
+ b.Click += (_, _) => onClick();
+ AutomationName(b, name);
+ return b;
+ }
+
+ static void AutomationName(UIElement e, string name) => System.Windows.Automation.AutomationProperties.SetName(e, name);
+
+ /// Rounded, no Windows 7 chrome. Plain buttons get a grey wash on hover; filled ones dim a little.
+ static ControlTemplate Template(bool plain, bool onDark = false, Type? target = null)
+ {
+ var t = new ControlTemplate(target ?? typeof(Button));
+ var border = new FrameworkElementFactory(typeof(Border), "bg");
+ border.SetValue(Border.CornerRadiusProperty, new CornerRadius(4));
border.SetBinding(Border.BackgroundProperty, new System.Windows.Data.Binding("Background") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.SetBinding(Border.BorderBrushProperty, new System.Windows.Data.Binding("BorderBrush") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
+ border.SetBinding(Border.BorderThicknessProperty, new System.Windows.Data.Binding("BorderThickness") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
border.SetBinding(Border.PaddingProperty, new System.Windows.Data.Binding("Padding") { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });
var content = new FrameworkElementFactory(typeof(ContentPresenter));
content.SetValue(ContentPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Center);
@@ -99,34 +193,160 @@ static class Ui
border.AppendChild(content);
t.VisualTree = border;
var hover = new Trigger { Property = UIElement.IsMouseOverProperty, Value = true };
- hover.Setters.Add(new Setter(UIElement.OpacityProperty, 0.85));
- t.Triggers.Add(hover);
+ var pressed = new Trigger { Property = ButtonBase.IsPressedProperty, Value = true };
+ if (plain)
+ {
+ var wash = onDark ? new SolidColorBrush(Color.FromArgb(0x26, 0xFF, 0xFF, 0xFF)) : (Brush)Palette.Subtle;
+ hover.Setters.Add(new Setter(Border.BackgroundProperty, wash, "bg"));
+ pressed.Setters.Add(new Setter(Border.BackgroundProperty, onDark ? new SolidColorBrush(Color.FromArgb(0x40, 0xFF, 0xFF, 0xFF)) : Palette.Selected, "bg"));
+ }
+ else
+ {
+ hover.Setters.Add(new Setter(UIElement.OpacityProperty, 0.9));
+ pressed.Setters.Add(new Setter(UIElement.OpacityProperty, 0.8));
+ }
+ var disabled = new Trigger { Property = UIElement.IsEnabledProperty, Value = false };
+ disabled.Setters.Add(new Setter(UIElement.OpacityProperty, 0.45));
+ t.Triggers.Add(hover); t.Triggers.Add(pressed); t.Triggers.Add(disabled);
return t;
}
- /// A text link in the link colour.
- public static TextBlock LinkText(string label, Action onClick)
+ /// A text link in the accent's text shade. Acts on press and marks it handled, so the notes
+ /// window doesn't start a drag instead.
+ public static TextBlock LinkText(string label, Action onClick, double size = 13)
{
- var t = Text(label, 12, Palette.Link, FontWeights.SemiBold, wrap: false);
+ var t = Text(label, size, Palette.AccentText, FontWeights.SemiBold, wrap: false);
t.Cursor = Cursors.Hand;
- // On press, and handled, so the notes window doesn't start dragging instead.
t.MouseLeftButtonDown += (_, e) => { e.Handled = true; onClick(); };
+ t.MouseEnter += (_, _) => t.TextDecorations = TextDecorations.Underline;
+ t.MouseLeave += (_, _) => t.TextDecorations = null;
return t;
}
- /// The small round "live" dot.
- public static FrameworkElement Dot(Brush color, double size = 8) => new System.Windows.Shapes.Ellipse { Width = size, Height = size, Fill = color };
+ public static FrameworkElement Dot(Brush color, double size = 8) => new Ellipse { Width = size, Height = size, Fill = color, VerticalAlignment = VerticalAlignment.Center };
- /// The badge shown when the window is visible in screen sharing (共享屏幕时让对方看到).
- public static Border Badge(string text) => new()
+ /// The live dot, breathing while listening.
+ public static FrameworkElement LiveDot(double size = 8)
{
- Background = Palette.AccentPale, CornerRadius = new CornerRadius(8), Padding = new Thickness(7, 2, 7, 2),
- Child = Text(text, 10, Palette.Link, FontWeights.SemiBold, wrap: false),
+ var dot = new Ellipse { Width = size, Height = size, Fill = Palette.Live, VerticalAlignment = VerticalAlignment.Center };
+ var pulse = new System.Windows.Media.Animation.DoubleAnimation(1, 0.35, TimeSpan.FromSeconds(0.9)) { AutoReverse = true, RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever };
+ dot.Loaded += (_, _) => dot.BeginAnimation(UIElement.OpacityProperty, pulse);
+ return dot;
+ }
+
+ /// A small pill: 对方可见 and the like.
+ public static Border Badge(string text, Brush? bg = null, Brush? fg = null) => new()
+ {
+ Background = bg ?? Palette.AccentPale, CornerRadius = new CornerRadius(10), Padding = new Thickness(8, 2, 8, 3), VerticalAlignment = VerticalAlignment.Center,
+ Child = Text(text, 12, fg ?? Palette.AccentText, FontWeights.SemiBold, wrap: false),
};
- public static ComboBox Choice(IEnumerable<(string value, string label)> options, string selected, Action<string> changed)
+ public static Border Card(UIElement child, Thickness? padding = null, Brush? bg = null) => new()
+ {
+ Background = bg ?? Palette.Surface, BorderBrush = Palette.Stroke, BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(8),
+ Padding = padding ?? new Thickness(16), Child = child,
+ };
+
+ public enum Severity { Error, Warning }
+
+ /// Fluent's InfoBar: an icon, a bold title, one line of body, and up to one action.
+ public static Border InfoBar(Severity severity, string? title, string body, UIElement? action = null)
{
- var box = new ComboBox { MinWidth = 180, FontFamily = Palette.Font, FontSize = 13 };
+ var error = severity == Severity.Error;
+ var icon = new Grid { Width = 18, Height = 18, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 1, 0, 0) };
+ 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));
+ var bodyText = Text(body, 13, Palette.Body);
+ if (title is not null) bodyText.Margin = new Thickness(0, 2, 0, 0);
+ text.Children.Add(bodyText);
+ var dock = new DockPanel();
+ DockPanel.SetDock(icon, Dock.Left);
+ dock.Children.Add(icon);
+ if (action is TextBlock link) { link.Margin = new Thickness(0, 6, 0, 0); link.HorizontalAlignment = HorizontalAlignment.Left; text.Children.Add(link); }
+ else if (action is FrameworkElement a) { DockPanel.SetDock(a, Dock.Right); a.VerticalAlignment = VerticalAlignment.Top; dock.Children.Add(a); }
+ dock.Children.Add(text);
+ return new Border
+ {
+ Background = error ? Palette.ErrorBg : Palette.WarnBg, BorderBrush = error ? Palette.ErrorStroke : Palette.WarnStroke,
+ BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(6), Padding = new Thickness(14, 12, 12, 12), Child = dock,
+ };
+ }
+
+ /// The Windows 11 toggle switch (role switch), with 开/关 beside it as Settings does.
+ public static FrameworkElement Switch(bool on, Action<bool> changed, string name)
+ {
+ var state = Text(on ? L("开") : L("关"), 13, Palette.Body, wrap: false);
+ var knob = new Ellipse { Width = 12, Height = 12 };
+ var track = new Border { Width = 40, Height = 20, CornerRadius = new CornerRadius(10), BorderThickness = new Thickness(1), Child = knob, Padding = new Thickness(3, 0, 3, 0) };
+ void Paint(bool v)
+ {
+ track.Background = v ? Palette.Ink : Palette.Surface;
+ track.BorderBrush = v ? Palette.Ink : Palette.Secondary;
+ knob.Fill = v ? Brushes.White : Palette.Secondary;
+ knob.HorizontalAlignment = v ? HorizontalAlignment.Right : HorizontalAlignment.Left;
+ state.Text = v ? L("开") : L("关");
+ }
+ Paint(on);
+ var toggle = new ToggleButton { IsChecked = on, Content = track, Background = Brushes.Transparent, BorderThickness = new Thickness(0), Cursor = Cursors.Hand, Padding = new Thickness(0) };
+ toggle.Template = Template(plain: false, target: typeof(ToggleButton));
+ toggle.Click += (_, _) => { var v = toggle.IsChecked == true; Paint(v); changed(v); };
+ AutomationName(toggle, name);
+ return Row(12, state, toggle);
+ }
+
+ /// 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)
+ {
+ var track = new Border { Background = Palette.Subtle, CornerRadius = new CornerRadius(6), Padding = new Thickness(2) };
+ var row = new StackPanel { Orientation = Orientation.Horizontal };
+ track.Child = row;
+ var buttons = new List<(Button b, string v)>();
+ void Paint(string v)
+ {
+ foreach (var (b, value) in buttons)
+ {
+ var on = value == v;
+ b.Background = on ? Palette.Surface : Brushes.Transparent;
+ b.Effect = on ? new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 3, ShadowDepth = 1, Opacity = 0.15 } : null;
+ ((TextBlock)b.Content).FontWeight = on ? FontWeights.SemiBold : FontWeights.Normal;
+ ((TextBlock)b.Content).Foreground = on ? Palette.Ink : Palette.Body;
+ }
+ }
+ foreach (var (value, label) in options)
+ {
+ var b = new Button { Content = Text(label, 13, Palette.Body, wrap: false), Height = 30, Padding = new Thickness(12, 0, 12, 0), BorderThickness = new Thickness(0), Cursor = Cursors.Hand };
+ b.Template = Template(plain: false);
+ b.Click += (_, _) => { Paint(value); changed(value); };
+ buttons.Add((b, value));
+ row.Children.Add(b);
+ }
+ Paint(selected);
+ return track;
+ }
+
+ /// Pivot-style tabs: text with an ink underline on the chosen one.
+ public static FrameworkElement Tabs(IEnumerable<(string value, string label)> options, string selected, Action<string> changed, double size = 14)
+ {
+ var row = new StackPanel { Orientation = Orientation.Horizontal };
+ 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 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);
+ b.Click += (_, _) => changed(value);
+ row.Children.Add(b);
+ }
+ return row;
+ }
+
+ public static ComboBox Choice(IEnumerable<(string value, string label)> options, string selected, Action<string> changed, double width = 200)
+ {
+ var box = new ComboBox { Width = width, FontFamily = Palette.Font, FontSize = 13, VerticalAlignment = VerticalAlignment.Center };
foreach (var (value, label) in options)
{
var item = new ComboBoxItem { Content = label, Tag = value };
@@ -138,13 +358,18 @@ static class Ui
}
public static IEnumerable<(string, string)> TargetOptions() =>
- [("system", L("跟随系统")), .. Languages.Targets.Select(t => (t.Code, t.Name))];
+ [("system", LF("跟随系统(%@)", Languages.Targets.FirstOrDefault(t => t.Code == Languages.FromSystem(System.Globalization.CultureInfo.CurrentUICulture.Name))?.Name ?? "")),
+ .. Languages.Targets.Select(t => (t.Code, t.Name))];
+
+ public static string TargetName(string code) => Languages.Targets.FirstOrDefault(t => t.Code == code)?.Name ?? code;
- public static Window StyledWindow(string title, double width, double height) => new()
+ /// The name of a spoken language as people write it ("English", "日本語").
+ public static string SpokenName(string? code)
{
- Title = title, Width = width, Height = height, Background = Palette.Ground, FontFamily = Palette.Font,
- WindowStartupLocation = WindowStartupLocation.CenterScreen, Icon = AppIcon.Image,
- };
+ if (code is null) return "";
+ var head = code.Split('-')[0];
+ return Languages.Sources.FirstOrDefault(s => s.Code.Split('-')[0] == head)?.Name ?? code;
+ }
}
static class AppIcon
@@ -156,4 +381,6 @@ static class AppIcon
try { return System.Windows.Media.Imaging.BitmapFrame.Create(new Uri("pack://application:,,,/cicada.ico")); }
catch { return null; }
}
+
+ public static Image Small(double size = 16) => new() { Source = Image, Width = size, Height = size, VerticalAlignment = VerticalAlignment.Center };
}