------ #### V1.0.2404.1201 - 新增支持手动运行规则。 - 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。 - 修复规则中播放文件夹可能导致无法执行的BUG。 - 修复规则不勾选礼物和点赞,则无法执行的BUG。
94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using CommunityToolkit.Mvvm.Messaging;
|
|
using DotNet4.Utilities;
|
|
using HandyControl.Controls;
|
|
using LiveTools.Data;
|
|
using LiveTools.RuleItem;
|
|
using Newtonsoft.Json.Linq;
|
|
using ryCommon;
|
|
using ryCommonDb;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace LiveTools
|
|
{
|
|
/// <summary>
|
|
/// Rule_ShowPic.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class Rule_ShowPic : UserControl, IRule
|
|
{
|
|
public Rule_ShowPic()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public string RuleID { get;} = "ShowPic";
|
|
public int ID { get; set; } = 0;
|
|
public void LoadSetting(JObject jo)
|
|
{
|
|
ChkPlaySound.IsChecked = jo.GetJsonValue("PlaySound", true);
|
|
var PicPath = API.GetTruePath(jo.GetJsonValue("PicPath", ""));
|
|
if (System.IO.File.Exists(PicPath))
|
|
{
|
|
PicSelector.SetValue(ImageSelector.UriPropertyKey, new Uri(PicPath));
|
|
PicSelector.SetValue(ImageSelector.PreviewBrushPropertyKey, new ImageBrush(BitmapFrame.Create(PicSelector.Uri, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.None))
|
|
{
|
|
Stretch = PicSelector.Stretch
|
|
});
|
|
PicSelector.SetCurrentValue(FrameworkElement.ToolTipProperty, PicPath);
|
|
}
|
|
NumPicSize.Value = jo.GetJsonValue("PicSize", 70);
|
|
NumPicCount.Value = jo.GetJsonValue("PicCount", 10);
|
|
}
|
|
public JObject SettingJson()
|
|
{
|
|
return new JObject()
|
|
{
|
|
{ "Name",this.GetType().Name},
|
|
{ "Mode",RuleID},
|
|
{ "PlaySound", ChkPlaySound.IsChecked ?? true },
|
|
{ "PicPath",API.GetRelativePath(PicSelector.Uri.LocalPath) },
|
|
{ "PicSize", NumPicSize.Value.ToInt() },
|
|
{ "PicCount", NumPicCount.Value.ToInt() },
|
|
};
|
|
}
|
|
public void Run(EffectInfo info, JObject jo)
|
|
{
|
|
|
|
}
|
|
public bool CheckVerification()
|
|
{
|
|
if (PicSelector.Uri == null)
|
|
{
|
|
HandyControl.Controls.MessageBox.Warning("请选择图片。", "提示");
|
|
return false;
|
|
}
|
|
if (!System.IO.File.Exists(PicSelector.Uri.LocalPath))
|
|
{
|
|
HandyControl.Controls.MessageBox.Warning("选择的图片不存在。", "提示");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void BtnClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
WeakReferenceMessenger.Default.Send<RuleMsg>(new RuleMsg() { ID = ID, Message="Close" });
|
|
}
|
|
}
|
|
}
|