mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-26 12:15:42 +08:00
6df6b96b2a
添加直播状态图标 添加复制主播名、房间号的右键菜单 调整高级设置 Cookie Textbox
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using ModernWpf.Controls;
|
|
|
|
namespace BililiveRecorder.WPF.Models
|
|
{
|
|
public class Commands : ICommand
|
|
{
|
|
#region Static Commands
|
|
|
|
public static Commands OpenLink { get; } = new Commands
|
|
{
|
|
ExecuteDelegate = o => { try { Process.Start(o.ToString()); } catch (Exception) { } }
|
|
};
|
|
|
|
public static Commands OpenContentDialog { get; } = new Commands
|
|
{
|
|
ExecuteDelegate = async o => { try { await (o as ContentDialog)?.ShowAsync(); } catch (Exception) { } }
|
|
};
|
|
|
|
public static Commands Copy { get; } = new Commands
|
|
{
|
|
ExecuteDelegate = e => { try { if (e is string str) Clipboard.SetText(str); } catch (Exception) { } }
|
|
};
|
|
|
|
#endregion
|
|
|
|
public Predicate<object> CanExecuteDelegate { get; set; }
|
|
public Action<object> ExecuteDelegate { get; set; }
|
|
|
|
#region ICommand Members
|
|
|
|
public void Execute(object parameter) => ExecuteDelegate?.Invoke(parameter);
|
|
|
|
public bool CanExecute(object parameter) => CanExecuteDelegate switch
|
|
{
|
|
null => true,
|
|
_ => CanExecuteDelegate(parameter),
|
|
};
|
|
|
|
public event EventHandler CanExecuteChanged
|
|
{
|
|
add { CommandManager.RequerySuggested += value; }
|
|
remove { CommandManager.RequerySuggested -= value; }
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|