Public Access
Add taskbar controls and summary oneliner
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using MeetingAssistant.LaunchProfiles;
|
||||
using MeetingAssistant.Recording;
|
||||
|
||||
namespace MeetingAssistant.Taskbar;
|
||||
|
||||
public enum MeetingTaskbarAction
|
||||
{
|
||||
StartRecording,
|
||||
StopRecording,
|
||||
AbortRecording,
|
||||
SwitchProfile
|
||||
}
|
||||
|
||||
public sealed record MeetingTaskbarMenu(
|
||||
RecordingProcessState State,
|
||||
string Tooltip,
|
||||
IReadOnlyList<MeetingTaskbarMenuItem> Items);
|
||||
|
||||
public sealed record MeetingTaskbarMenuItem(
|
||||
string Text,
|
||||
MeetingTaskbarAction Action,
|
||||
string? ProfileName = null);
|
||||
|
||||
public static class MeetingTaskbarMenuBuilder
|
||||
{
|
||||
public static MeetingTaskbarMenu Build(
|
||||
RecordingStatus status,
|
||||
IReadOnlyList<LaunchProfile> launchProfiles)
|
||||
{
|
||||
var items = new List<MeetingTaskbarMenuItem>();
|
||||
|
||||
if (status.IsRecording)
|
||||
{
|
||||
items.Add(new MeetingTaskbarMenuItem(
|
||||
"Stop meeting recording and transcribe",
|
||||
MeetingTaskbarAction.StopRecording));
|
||||
items.Add(new MeetingTaskbarMenuItem(
|
||||
"Cancel meeting recording and discard",
|
||||
MeetingTaskbarAction.AbortRecording));
|
||||
|
||||
foreach (var profile in launchProfiles.Where(profile => !IsActiveProfile(profile, status)))
|
||||
{
|
||||
items.Add(new MeetingTaskbarMenuItem(
|
||||
$"Switch to {profile.Name}",
|
||||
MeetingTaskbarAction.SwitchProfile,
|
||||
profile.Name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var profile in launchProfiles)
|
||||
{
|
||||
items.Add(new MeetingTaskbarMenuItem(
|
||||
$"Start meeting recording ({profile.Name})",
|
||||
MeetingTaskbarAction.StartRecording,
|
||||
profile.Name));
|
||||
}
|
||||
}
|
||||
|
||||
return new MeetingTaskbarMenu(
|
||||
status.State,
|
||||
BuildTooltip(status),
|
||||
items);
|
||||
}
|
||||
|
||||
private static string BuildTooltip(RecordingStatus status)
|
||||
{
|
||||
return status.State switch
|
||||
{
|
||||
RecordingProcessState.Recording => string.IsNullOrWhiteSpace(status.LaunchProfile)
|
||||
? "Meeting Assistant - recording"
|
||||
: $"Meeting Assistant - recording ({status.LaunchProfile})",
|
||||
RecordingProcessState.Summarizing => "Meeting Assistant - summarizing",
|
||||
_ => "Meeting Assistant - idle"
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsActiveProfile(
|
||||
LaunchProfile profile,
|
||||
RecordingStatus status)
|
||||
{
|
||||
return string.Equals(
|
||||
profile.Name,
|
||||
status.LaunchProfile,
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user