2020-11-27 18:51:02 +08:00
|
|
|
using System;
|
2020-12-12 23:19:47 +08:00
|
|
|
using System.Diagnostics;
|
2020-11-27 18:51:02 +08:00
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
using BililiveRecorder.Core;
|
2022-04-30 14:27:46 +08:00
|
|
|
using BililiveRecorder.WPF.Pages;
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-05-01 17:57:43 +08:00
|
|
|
#nullable enable
|
2020-11-27 18:51:02 +08:00
|
|
|
namespace BililiveRecorder.WPF.Controls
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Interaction logic for RoomCard.xaml
|
|
|
|
/// </summary>
|
|
|
|
public partial class RoomCard : UserControl
|
|
|
|
{
|
|
|
|
public RoomCard()
|
|
|
|
{
|
2021-01-01 14:46:27 +08:00
|
|
|
this.InitializeComponent();
|
2020-11-27 18:51:02 +08:00
|
|
|
}
|
|
|
|
|
2021-05-01 17:57:43 +08:00
|
|
|
public event EventHandler? DeleteRequested;
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-05-01 17:57:43 +08:00
|
|
|
public event EventHandler? ShowSettingsRequested;
|
2021-01-01 14:46:27 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void MenuItem_StartRecording_Click(object sender, RoutedEventArgs e) => (this.DataContext as IRoom)?.StartRecord();
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void MenuItem_StopRecording_Click(object sender, RoutedEventArgs e) => (this.DataContext as IRoom)?.StopRecord();
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void MenuItem_RefreshInfo_Click(object sender, RoutedEventArgs e) => (this.DataContext as IRoom)?.RefreshRoomInfoAsync();
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void MenuItem_StartMonitor_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (this.DataContext is IRoom room)
|
|
|
|
room.RoomConfig.AutoRecord = true;
|
|
|
|
}
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void MenuItem_StopMonitor_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (this.DataContext is IRoom room)
|
|
|
|
room.RoomConfig.AutoRecord = false;
|
|
|
|
}
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-01-08 18:54:50 +08:00
|
|
|
private void MenuItem_DeleteRoom_Click(object sender, RoutedEventArgs e) => DeleteRequested?.Invoke(this.DataContext, EventArgs.Empty);
|
2021-01-01 14:46:27 +08:00
|
|
|
|
2021-01-08 18:54:50 +08:00
|
|
|
private void MenuItem_ShowSettings_Click(object sender, RoutedEventArgs e) => ShowSettingsRequested?.Invoke(this.DataContext, EventArgs.Empty);
|
2020-11-27 18:51:02 +08:00
|
|
|
|
2021-02-23 18:03:37 +08:00
|
|
|
private void Button_Split_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (this.DataContext is IRoom room)
|
|
|
|
room.SplitOutput();
|
|
|
|
}
|
2020-12-12 23:19:47 +08:00
|
|
|
|
|
|
|
private void MenuItem_OpenInBrowser_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
2021-02-23 18:03:37 +08:00
|
|
|
if (this.DataContext is IRoom r && r is not null)
|
2020-12-12 23:19:47 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2021-02-23 18:03:37 +08:00
|
|
|
Process.Start("https://live.bilibili.com/" + r.RoomConfig.RoomId);
|
2020-12-12 23:19:47 +08:00
|
|
|
}
|
|
|
|
catch (Exception) { }
|
|
|
|
}
|
|
|
|
}
|
2022-04-30 14:27:46 +08:00
|
|
|
|
|
|
|
private void MenuItem_ShowGlobalSettings_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (RootPage.SwitchToSettingsPage is Action change)
|
|
|
|
{
|
|
|
|
change();
|
|
|
|
}
|
|
|
|
}
|
2020-11-27 18:51:02 +08:00
|
|
|
}
|
|
|
|
}
|