From 0ec1400de922718a879f855d6d1e7cf8e62e37aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=BD=93=E6=97=B6?= Date: Sat, 13 Apr 2024 10:13:30 +0800 Subject: [PATCH] =?UTF-8?q?###=202024-04-12=E6=9B=B4=E6=96=B0=20------=20#?= =?UTF-8?q?###=20=20V1.0.2404.1201=20-=20=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=89=8B=E5=8A=A8=E8=BF=90=E8=A1=8C=E8=A7=84=E5=88=99?= =?UTF-8?q?=E3=80=82=20-=20=E8=A7=84=E5=88=99=E6=92=AD=E6=94=BE=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=97=B4=E9=9A=94=E4=B8=8D=E5=86=8D=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=A3=B0=E6=95=88,=E8=80=8C=E5=8F=AA?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E5=BD=93=E5=89=8D=E8=A7=84=E5=88=99=E5=A3=B0?= =?UTF-8?q?=E6=95=88=E3=80=82=20-=20=E4=BF=AE=E5=A4=8D=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=B8=AD=E6=92=AD=E6=94=BE=E6=96=87=E4=BB=B6=E5=A4=B9=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=9A=84BUG=E3=80=82=20-=20=E4=BF=AE=E5=A4=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=8D=E5=8B=BE=E9=80=89=E7=A4=BC=E7=89=A9=E5=92=8C?= =?UTF-8?q?=E7=82=B9=E8=B5=9E=EF=BC=8C=E5=88=99=E6=97=A0=E6=B3=95=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84BUG=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + CHANGELOG.md | 10 + README.md | 2 + Source/API/SoundPlay.cs | 155 ++++++ Source/App.xaml | 15 + Source/App.xaml.cs | 29 ++ Source/AssemblyInfo.cs | 10 + Source/Config/API.cs | 117 +++++ Source/Config/Config.cs | 182 +++++++ Source/Config/Json.cs | 439 +++++++++++++++++ Source/Config/RyPostGet.cs | 121 +++++ Source/Config/UserInfo.cs | 34 ++ Source/Content/CustomWindow.cs | 33 ++ Source/Content/LeftMainContent.xaml | 67 +++ Source/Content/LeftMainContent.xaml.cs | 64 +++ Source/Content/MainContent.xaml | 17 + Source/Content/MainContent.xaml.cs | 97 ++++ Source/Content/MainWinContent.xaml | 22 + Source/Content/MainWinContent.xaml.cs | 110 +++++ Source/Data/ConstVar.cs | 79 ++++ Source/Data/GeometryIcon.xaml | 6 + Source/Data/LogViewModel.cs | 36 ++ Source/Data/MessageToken.cs | 41 ++ Source/FrmEffects.xaml | 13 + Source/FrmEffects.xaml.cs | 379 +++++++++++++++ Source/FrmWeb.xaml | 15 + Source/FrmWeb.xaml.cs | 447 ++++++++++++++++++ Source/LiveTools.csproj | 98 ++++ Source/LiveTools.csproj.user | 93 ++++ Source/LiveTools.sln | 25 + Source/MainWindow.xaml | 18 + Source/MainWindow.xaml.cs | 151 ++++++ Source/Pngs/Icons/home.png | Bin 0 -> 582 bytes Source/Pngs/Icons/主图.ico | Bin 0 -> 17710 bytes Source/Pngs/Icons/主图.png | Bin 0 -> 2187 bytes Source/Pngs/Icons/头像.png | Bin 0 -> 4354 bytes Source/Pngs/Icons/直播.png | Bin 0 -> 700 bytes Source/Pngs/Icons/规则引擎.png | Bin 0 -> 1214 bytes Source/Pngs/Icons/设置.png | Bin 0 -> 932 bytes .../PublishProfiles/FolderProfile.pubxml | 18 + .../PublishProfiles/FolderProfile.pubxml.user | 10 + Source/Properties/Settings.Designer.cs | 26 + Source/Properties/Settings.settings | 6 + Source/RuleItem/IRule.cs | 19 + Source/RuleItem/RuleMsg.cs | 14 + Source/RuleItem/Rule_ShowPic.xaml | 24 + Source/RuleItem/Rule_ShowPic.xaml.cs | 93 ++++ Source/RuleItem/Rule_SoundPlay.xaml | 28 ++ Source/RuleItem/Rule_SoundPlay.xaml.cs | 173 +++++++ Source/RuleItem/Rule_Variable.xaml | 25 + Source/RuleItem/Rule_Variable.xaml.cs | 91 ++++ Source/Tools/Direct/FrmAddDirect.xaml | 28 ++ Source/Tools/Direct/FrmAddDirect.xaml.cs | 78 +++ Source/Tools/Direct/FrmDirectView.xaml | 63 +++ Source/Tools/Direct/FrmDirectView.xaml.cs | 361 ++++++++++++++ Source/Tools/Login/FrmAccountInfo.xaml | 21 + Source/Tools/Login/FrmAccountInfo.xaml.cs | 70 +++ Source/Tools/Login/FrmLogin.xaml | 22 + Source/Tools/Login/FrmLogin.xaml.cs | 248 ++++++++++ Source/Tools/Login/FrmRegUser.xaml | 34 ++ Source/Tools/Login/FrmRegUser.xaml.cs | 117 +++++ Source/Tools/Login/FrmUseSN.xaml | 26 + Source/Tools/Login/FrmUseSN.xaml.cs | 60 +++ Source/Tools/Rules/FrmAddRule.xaml | 77 +++ Source/Tools/Rules/FrmAddRule.xaml.cs | 270 +++++++++++ Source/Tools/Rules/FrmRuleView.xaml | 30 ++ Source/Tools/Rules/FrmRuleView.xaml.cs | 173 +++++++ Source/Tools/Rules/GiftItem.xaml | 10 + Source/Tools/Rules/GiftItem.xaml.cs | 41 ++ Source/Tools/Setting/FrmSetting.xaml | 33 ++ Source/Tools/Setting/FrmSetting.xaml.cs | 57 +++ Source/主图.ico | Bin 0 -> 91394 bytes 72 files changed, 5274 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 Source/API/SoundPlay.cs create mode 100644 Source/App.xaml create mode 100644 Source/App.xaml.cs create mode 100644 Source/AssemblyInfo.cs create mode 100644 Source/Config/API.cs create mode 100644 Source/Config/Config.cs create mode 100644 Source/Config/Json.cs create mode 100644 Source/Config/RyPostGet.cs create mode 100644 Source/Config/UserInfo.cs create mode 100644 Source/Content/CustomWindow.cs create mode 100644 Source/Content/LeftMainContent.xaml create mode 100644 Source/Content/LeftMainContent.xaml.cs create mode 100644 Source/Content/MainContent.xaml create mode 100644 Source/Content/MainContent.xaml.cs create mode 100644 Source/Content/MainWinContent.xaml create mode 100644 Source/Content/MainWinContent.xaml.cs create mode 100644 Source/Data/ConstVar.cs create mode 100644 Source/Data/GeometryIcon.xaml create mode 100644 Source/Data/LogViewModel.cs create mode 100644 Source/Data/MessageToken.cs create mode 100644 Source/FrmEffects.xaml create mode 100644 Source/FrmEffects.xaml.cs create mode 100644 Source/FrmWeb.xaml create mode 100644 Source/FrmWeb.xaml.cs create mode 100644 Source/LiveTools.csproj create mode 100644 Source/LiveTools.csproj.user create mode 100644 Source/LiveTools.sln create mode 100644 Source/MainWindow.xaml create mode 100644 Source/MainWindow.xaml.cs create mode 100644 Source/Pngs/Icons/home.png create mode 100644 Source/Pngs/Icons/主图.ico create mode 100644 Source/Pngs/Icons/主图.png create mode 100644 Source/Pngs/Icons/头像.png create mode 100644 Source/Pngs/Icons/直播.png create mode 100644 Source/Pngs/Icons/规则引擎.png create mode 100644 Source/Pngs/Icons/设置.png create mode 100644 Source/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 Source/Properties/PublishProfiles/FolderProfile.pubxml.user create mode 100644 Source/Properties/Settings.Designer.cs create mode 100644 Source/Properties/Settings.settings create mode 100644 Source/RuleItem/IRule.cs create mode 100644 Source/RuleItem/RuleMsg.cs create mode 100644 Source/RuleItem/Rule_ShowPic.xaml create mode 100644 Source/RuleItem/Rule_ShowPic.xaml.cs create mode 100644 Source/RuleItem/Rule_SoundPlay.xaml create mode 100644 Source/RuleItem/Rule_SoundPlay.xaml.cs create mode 100644 Source/RuleItem/Rule_Variable.xaml create mode 100644 Source/RuleItem/Rule_Variable.xaml.cs create mode 100644 Source/Tools/Direct/FrmAddDirect.xaml create mode 100644 Source/Tools/Direct/FrmAddDirect.xaml.cs create mode 100644 Source/Tools/Direct/FrmDirectView.xaml create mode 100644 Source/Tools/Direct/FrmDirectView.xaml.cs create mode 100644 Source/Tools/Login/FrmAccountInfo.xaml create mode 100644 Source/Tools/Login/FrmAccountInfo.xaml.cs create mode 100644 Source/Tools/Login/FrmLogin.xaml create mode 100644 Source/Tools/Login/FrmLogin.xaml.cs create mode 100644 Source/Tools/Login/FrmRegUser.xaml create mode 100644 Source/Tools/Login/FrmRegUser.xaml.cs create mode 100644 Source/Tools/Login/FrmUseSN.xaml create mode 100644 Source/Tools/Login/FrmUseSN.xaml.cs create mode 100644 Source/Tools/Rules/FrmAddRule.xaml create mode 100644 Source/Tools/Rules/FrmAddRule.xaml.cs create mode 100644 Source/Tools/Rules/FrmRuleView.xaml create mode 100644 Source/Tools/Rules/FrmRuleView.xaml.cs create mode 100644 Source/Tools/Rules/GiftItem.xaml create mode 100644 Source/Tools/Rules/GiftItem.xaml.cs create mode 100644 Source/Tools/Setting/FrmSetting.xaml create mode 100644 Source/Tools/Setting/FrmSetting.xaml.cs create mode 100644 Source/主图.ico diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e0ba8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +obj +bin +.vs diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c77f72d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +### 2024-04-12更新 + +------ + +#### V1.0.2404.1201 + +- 新增支持手动运行规则。 +- 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。 +- 修复规则中播放文件夹可能导致无法执行的BUG。 +- 修复规则不勾选礼物和点赞,则无法执行的BUG。 diff --git a/README.md b/README.md new file mode 100644 index 0000000..94f998f --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# 紫林直播助手 +紫林直播助手可以帮助你在直播过程中自动执行礼物特效、播放特定声音等操作。 \ No newline at end of file diff --git a/Source/API/SoundPlay.cs b/Source/API/SoundPlay.cs new file mode 100644 index 0000000..8c006b5 --- /dev/null +++ b/Source/API/SoundPlay.cs @@ -0,0 +1,155 @@ +using NAudio.Wave; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Windows; +using System.Windows.Forms; + +namespace LiveTools +{ + public class SoundPlay + { + private readonly WaveOut waveOut = null; + /// + /// 实例化音频播放类 + /// + public SoundPlay() + { + waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()); + } + /// + /// 实例化音频播放类 + /// + /// + public SoundPlay(string path) + { + waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()); + FilePath = path; + } + /// + /// 音频文件地址 + /// + public string FilePath { get; set; } + public event EventHandler OnPlayEnd; + /// + /// 播放 + /// + public void Play() + { + Play(FilePath); + } + /// + /// 播放指定音频 + /// + /// + public void Play(string path) + { + if (!System.IO.File.Exists(path)) { return; } + try + { + //var ms = System.IO.File.OpenRead(path); + var rdr1 = new AudioFileReader(path); + waveOut?.Init(rdr1); + waveOut?.Play(); + while(waveOut.PlaybackState== PlaybackState.Playing) + { + System.Windows.Forms.Application.DoEvents(); + Thread.Sleep(10); + } + } + catch(Exception ex) + { } + } + /// + /// 播放状态 + /// + public PlaybackState PlaybackState + { + get { return waveOut.PlaybackState; } + } + /// + /// 异步播放指定音频 + /// + /// + public void PlaySync(string path) + { + if (!System.IO.File.Exists(path)) { return; } + Thread th = new Thread(delegate() { + Play(path); + OnPlayEnd?.Invoke(this,new EventArgs()); + }); + th.Start(); + } + /// + /// 停止播放 + /// + public void Stop() + { + try + { + waveOut?.Stop(); + } + catch + { + } + } + /// + /// 恢复播放 + /// + public void Resume() + { + try + { + waveOut.Resume(); + } + catch + { + } + } + /// + /// 暂停播放 + /// + public void Pause() + { + try + { + waveOut.Pause(); + } + catch + { + } + } + /// + /// 设置/获取音量,范围为0-1 + /// + public float Volume + { + get { return waveOut.Volume; } + set + { + try + { + waveOut.Volume = value; + } + catch(Exception ex) + { + } + } + } + /// + /// 销毁数据 + /// + ~SoundPlay() + { + try + { + waveOut.Dispose(); + } + catch + { + } + } + } +} diff --git a/Source/App.xaml b/Source/App.xaml new file mode 100644 index 0000000..7d1ecfe --- /dev/null +++ b/Source/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/Source/App.xaml.cs b/Source/App.xaml.cs new file mode 100644 index 0000000..7077177 --- /dev/null +++ b/Source/App.xaml.cs @@ -0,0 +1,29 @@ +using System.Configuration; +using System.Data; +using System.Runtime.InteropServices; +using System.Windows; + +namespace LiveTools +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private static Mutex mutex = null; + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + bool isFirstInstance; + mutex = new Mutex(true,Config.SoftId, out isFirstInstance); + + if (!isFirstInstance) + { + //MessageBox.Show("应用程序已经在运行。"); + Current.Shutdown(); + } + } + } + +} diff --git a/Source/AssemblyInfo.cs b/Source/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/Source/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Source/Config/API.cs b/Source/Config/API.cs new file mode 100644 index 0000000..c8b945d --- /dev/null +++ b/Source/Config/API.cs @@ -0,0 +1,117 @@ +using CommunityToolkit.Mvvm.Messaging; +using DotNet4.Utilities; +using LiveTools.Data; +using Microsoft.VisualBasic.ApplicationServices; +using ryCommon; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Threading; + +namespace LiveTools +{ + public class API + { + /// + /// 检查登录 + /// + /// + /// + public static int CheckedLogin(out string ErrorMsg) + { + try + { + ErrorMsg = ""; + Config.UserInfo.NickName = ""; + Config.UserInfo.isOut = 1; + HttpResult html = Config.ry_api.Post(Config.Api_Url + "user.aspx", "api=login&userid=" + RyWeb.WebDecode.Escape(Config.UserInfo.UserId) + + "&soft_id=" + RyWeb.WebDecode.Escape(Config.SoftId) + "&pwd=" + RyWeb.WebDecode.Escape(Config.UserInfo.Pwd) + + "&ver=" + RyWeb.WebDecode.Escape(RySoft.VersionStr) + "&hdid=" + RyWeb.WebDecode.Escape(Config.GetMac()) + "&login=1"); + string jsonText = GetJson(html.Html); + if (jsonText != "") + { + Json json = new Json(jsonText); + string result = json.GetJsonValue(Data.ConstVar.json_Result); + if (result == Data.ResultVar.json_Success.ToString()) + { + Config.UserInfo.NickName = json.GetJsonValue("nickname"); + Config.UserInfo.OutDateStr = json.GetJsonValue("out_date"); + Config.UserInfo.OutTime = Config.UserInfo.OutDateStr.ToDateTime().ToInt64(); + Config.UserInfo.isOut = json.GetJsonValue("isout").ToInt(); + Config.UserInfo.PriceAds = json.GetJsonValue("PriceAds", "月卡59元,季卡99元,年卡199元,永久卡299元"); + Config.UserInfo.BuyContact = json.GetJsonValue("BuyContact", "邮箱:1017848709@qq.com"); + //ClsPram.ZZ_Op = json.GetJsonValue("zz_op").ToInt(); + Config.UserInfo.Media_id = json.GetJsonValue("media_id"); + Config.UserInfo.Setting = json.GetJsonValue("setting"); + Config.UserInfo.Sys_Setting = json.GetJsonValue("sys_setting"); + Config.UserInfo.Parent_Setting = json.GetJsonValue("parent_setting"); + Config.UserInfo.Ads_id = json.GetJsonValue("ads_id"); + return 1; + } + else if (result == Data.ResultVar.json_UserOutDate.ToString()) + { + Config.UserInfo.isOut = 1; + ErrorMsg = "当前账号需要续费才能使用,请续费。"; + return -1000;//需要续费 + } + else + { + ErrorMsg = json.GetJsonValue(ConstVar.json_ResultText); + //HandyControl.Controls.MessageBox.Show(json.GetJsonValue(ConstVar.json_ResultText), "错误代码:" + result); + return -1; + } + } + else + { + ErrorMsg ="服务器异常,请检查网络连接"; + return -100;//服务器异常 + } + } + catch { ErrorMsg = "检查登录过程中发生错误。"; return -2; } + } + public static bool IsJson(string result) + { + if (result.Length <= 6) + { + return false; + } + else if (result.Substring(0, 1) == "1") + { + return true; + } + else + { return false; } + } + public static string GetJson(string result) + { + if (IsJson(result)) + { + return result.Substring(6); + } + else + { + return ""; + } + } + /// + /// 获取相对路径 + /// + /// + /// + public static string GetRelativePath(string fullPath) + { + return fullPath.Replace(Config.GetCurrentFolder,"{app}",true, System.Globalization.CultureInfo.CurrentCulture); + } + /// + /// 获取相对路径 + /// + /// + /// + public static string GetTruePath(string fullPath) + { + return fullPath.Replace("{app}", Config.GetCurrentFolder); + } + } +} diff --git a/Source/Config/Config.cs b/Source/Config/Config.cs new file mode 100644 index 0000000..3c8ec0d --- /dev/null +++ b/Source/Config/Config.cs @@ -0,0 +1,182 @@ +using ryCommon; +using ryCommonDb; +using rySafe; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Net.NetworkInformation; +using System.Text; +using System.Threading.Tasks; + +namespace LiveTools +{ + public class Config + { + public static bool InitCef { get; set; } = false; + public static int isAutoLogin = 0; + public static UserInfo UserInfo { get; set; } = new UserInfo(); + public static string Api_Url = "http://reg.itjs.top/API/"; + public static string SoftId = "LiveTools"; + public static bool MustUpdate = false; + public static string NewVerUrl = ""; + public static RyPostGet ry_api = new RyPostGet(); + /// + /// 默认礼物特效 + /// + public static bool GiftTrigger { get; set; } = true; + public static bool PlaySound { get; set; } = true; + /// + /// 是否允许多个声音同时播放 + /// + public static bool MultiPlaySound { get; set; } = true; + public static int PicSize { get; set; } = 70; + public static int PicCount { get; set; } = 10; + /// + /// 礼物缓存 + /// + public static Hashtable GiftCache { get; set; } = new Hashtable(); + public static UsingLock GiftLock { get; set; } = new UsingLock(); + public static void LoadSetting() + { + Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder + "\\Setting.json")); + GiftTrigger = json.GetJsonValue("GiftTrigger", true); + PlaySound = json.GetJsonValue("PlaySound", true); + MultiPlaySound = json.GetJsonValue("MultiPlaySound", true); + PicSize = json.GetJsonValue("PicSize", 70); + PicCount = json.GetJsonValue("PicCount", 10); + } + /// + /// 数据库完整路径 + /// + public static string DbFullPath + { + get + { + return UserDbFolder + "\\MyDb.dat"; + } + } + public static string GetCurrentFolder + { + get + { + return System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName??"").TrimEnd('\\') ??""; + } + } + /// + /// 系统数据文件夹 + /// + public static string SysDbFolder + { + get + { + return GetCurrentFolder + "\\SysDb"; + } + } + /// + /// 所有用户数据文件夹 + /// + public static string AllUserDbFolder + { + get + { + return GetCurrentFolder + "\\UserDb"; + } + } + /// + /// 用户数据文件夹 + /// + public static string UserDbFolder + { + get + { + if(UserInfo.UserId.Length>0) + { + return GetCurrentFolder + "\\UserDb\\"+ UserInfo.UserId; + } + return GetCurrentFolder + "\\UserDb"; + } + } + /// + /// 创建数据库 + /// + public static void CreateDb() + { + IDbInterface db = new SQLiteDataProvider(); + if (db.ConnDb(DbFullPath) == 1) + { + #region 规则表 + RyQuickSQL mySQL = new("Rules"); + mySQL.AddField("RuleName", ""); + mySQL.AddField("SortIndex", 0d); + mySQL.AddField("RuleJson", ""); + mySQL.AddField("AddTime", 0L); + mySQL.AddField("EditTime", 0L); + db.CreateDb(mySQL); + #endregion + #region 直播表 + mySQL.Clear(); + mySQL.TableName = "Direct"; + mySQL.AddField("Name", ""); + mySQL.AddField("Platform", ""); + mySQL.AddField("DirectId", ""); + mySQL.AddField("DirectJson", ""); + mySQL.AddField("AddTime", 0L); + mySQL.AddField("EditTime", 0L); + db.CreateDb(mySQL); + #endregion + // + } + } + /// + /// 为1表示登录 + /// + /// + public static int IsLogin() + { + if (UserInfo.UserId.Length == 0) + { + return 0; + } + if (UserInfo.UserId.Length>0 && UserInfo.OutTime>=DateTime.Now.ToInt64()) + { + return 1; + } + return -1; + } + public static string GetMac() + { + IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); + NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); + // HostName = computerProperties.HostName; + Console.WriteLine("Interface information for {0}.{1} ", + computerProperties.HostName, computerProperties.DomainName); + if (nics == null || nics.Length < 1) + { + return ""; + } + foreach (NetworkInterface adapter in nics) + { + IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties(); + string Description = adapter.Description;//接口的描述 + string NetworkInterfaceType = adapter.NetworkInterfaceType.ToString();//获取接口类型 + PhysicalAddress address = adapter.GetPhysicalAddress();//返回MAC地址 + if (NetworkInterfaceType != "Loopback" && NetworkInterfaceType == "Ethernet") + + return adapter.GetPhysicalAddress().ToString(); + //byte[] bytes = address.GetAddressBytes(); + //for (int i = 0; i < bytes.Length; i++) + //{ + // //.ToString("X2") 将byte数组转换成字符串 + // Console.Write("{0}", bytes[i].ToString("X2")); + // if (i != bytes.Length - 1) + // { + // Console.Write("-"); + // } + //} + } + return ""; + } + } +} diff --git a/Source/Config/Json.cs b/Source/Config/Json.cs new file mode 100644 index 0000000..5bd4355 --- /dev/null +++ b/Source/Config/Json.cs @@ -0,0 +1,439 @@ +using LiveTools; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using ryCommon; +using System; +using System.Data; + +/// +/// json 的摘要说明 +/// +public class Json +{ + private string jsonText = ""; + /// + /// + /// + public JObject jo; + /// + /// + /// + public Json() + { + jo = new JObject(); + } + /// + /// + /// + public string Html { get; private set; } = ""; + /// + /// + /// + public Json(JObject jo) + { + this.jo = jo; + } + private void LoadJson(string _jsonText) + { + Html = _jsonText; + if (_jsonText == null) { jo = new JObject(); return; } + if (_jsonText.Length == 0) + { + jo = new JObject(); return; + } + string xx = _jsonText.GetStr("descUrl", "counterApi"); + jsonText = _jsonText.Replace("+new Date,", "'',"); + jsonText = jsonText.Replace("!true,", "false,"); + if (xx.Length > 0) { jsonText = jsonText.Replace(xx, " :'',\r\n "); } + try + { + if (jsonText.Length == 0) + { jo = new JObject(); } + else + jo = (JObject)JsonConvert.DeserializeObject(jsonText); + } + catch (Exception) + { + jo = new JObject(); + } + } + /// + /// + /// + /// + public Json(string _jsonText) + { + LoadJson(_jsonText); + } + /// + /// 获取或设置json文本 + /// + public string Text + { + get { return jo.ToString(); } + set + { + jsonText = value; + if (value.Length == 0) + { + jo = new JObject(); + } + else + { + jo = (JObject)JsonConvert.DeserializeObject(value); + } + } + } + /// + /// + /// + /// + /// + public string GetJsonValue(string name) + { + if (jo[name] == null) { return ""; } + else + { return jo[name].ToString(); } + } + /// + /// + /// + /// + /// + /// + public string GetJsonValue(string name, string defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToString(); } + } + /// + /// + /// + /// + /// + /// + public bool GetJsonValue(string name, bool defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { + string value = jo[name].ToString().ToLower(); + return value == "1" || value == "true"; + } + } + /// + /// + /// + /// + /// + /// + public int GetJsonValue(string name, int defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToInt(defvalue); } + } + /// + /// + /// + /// + /// + /// + /// + /// + public int GetJsonValue(string name, int min, int max, int defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToInt(min, max, defvalue); } + } + /// + /// + /// + /// + /// + /// + /// + /// + public decimal GetJsonValue(string name, decimal min, decimal max, decimal defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToDecimal(min, max, defvalue); } + } + /// + /// + /// + /// + /// + /// + public Int64 GetJsonValue(string name, Int64 defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToInt64(defvalue); } + } + /// + /// + /// + /// + /// + /// + public decimal GetJsonValue(string name, decimal defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToDecimal(defvalue); } + } + + /// + /// + /// + /// + /// + /// + public double GetJsonValue(string name, double defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { return jo[name].ToDouble(defvalue); } + } + /// + /// + /// + /// + /// + /// + public JObject GetJsonValue(string name, JObject defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { + try + { + return (JObject)jo[name]; + } + catch { return defvalue; } + } + } + /// + /// + /// + /// + /// + /// + public JArray GetJsonValue(string name, JArray defvalue) + { + if (jo[name] == null) { return defvalue; } + else + { + try + { + return (JArray)jo[name]; + } + catch { return defvalue; } + } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, decimal defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue.ToString(); } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, int defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue.ToString(); } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, string defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue; } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, bool defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue ? 1 : 0; } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, JObject defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue; } + } + /// + /// + /// + /// + /// + /// + public void SetJsonValue(string name, JArray defvalue) + { + if (jo[name] == null) { Add(name, defvalue); } + else + { jo[name] = defvalue; } + } + /// + /// + /// + /// + /// + public DataTable GetJsonValueByTable(string name) + { + if (jo[name] == null) { return new DataTable(); } + else + { + try + { + return JsonConvert.DeserializeObject(jo[name].ToString(), typeof(DataTable)) as DataTable; + } + catch { return new DataTable(); } + } + } + /// + /// + /// + /// + /// + public void Add(string Name, string value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, JObject value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, JArray value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, int value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, long value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, bool value) + { + try + { + jo.Add(Name, value ? 1 : 0); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, decimal value) + { + try + { + jo.Add(Name, value); + } + catch { } + } + /// + /// + /// + /// + /// + public void Add(string Name, DataTable value) + { + try + { + jo.Add(Name, Newtonsoft.Json.JsonConvert.SerializeObject(value)); + } + catch { } + } + /// + /// 返回Json + /// + /// + public override string ToString() + { + return this.Text; + } +} \ No newline at end of file diff --git a/Source/Config/RyPostGet.cs b/Source/Config/RyPostGet.cs new file mode 100644 index 0000000..9931470 --- /dev/null +++ b/Source/Config/RyPostGet.cs @@ -0,0 +1,121 @@ +using DotNet4.Utilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LiveTools +{ + public class RyPostGet + { + /// + /// 以post方式获取网页源码 + /// + /// + /// + /// + /// + public HttpResult Post(string url, string post, string cookie) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url, + Postdata = post, + ContentType = "application/x-www-form-urlencoded", + Method = "POST", + Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", + Expect100Continue = false + }; + if (cookie != "") + { + m.Cookie = cookie; + } + HttpResult r = t.GetHtml(m); + return r; + } + catch + { + HttpResult r = new HttpResult(); + return r; + } + } + /// + /// 以post方式获取网页源码 + /// + /// + /// + /// + public HttpResult Post(string url, string post) + { + return Post(url, post, cookie); + } + /// + /// 获取网页源码 + /// + /// + /// + /// + public HttpResult Get(string url, string cookie) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url + }; + if (cookie != "") + { + m.Cookie = cookie; + } + m.Allowautoredirect = true; + HttpResult r = t.GetHtml(m); + return r; + } + catch + { + HttpResult r = new HttpResult(); + return r; + } + } + /// + /// 获取网页源码 + /// + /// + /// + public HttpResult Get(string url) + { + return Get(url, cookie); + } + public string Cookie + { + get { return cookie; } + set { cookie = value; } + } + private string cookie = ""; + public static string UrlEncode(string str) + { + StringBuilder sb = new StringBuilder(); + byte[] byStr = System.Text.Encoding.UTF8.GetBytes(str); //默认是System.Text.Encoding.Default.GetBytes(str) + for (int i = 0; i < byStr.Length; i++) + { + sb.Append(@"%" + Convert.ToString(byStr[i], 16)); + } + + return (sb.ToString()); + } + public static string GetMD5(string str) + { + StringBuilder sb = new StringBuilder(); + foreach (byte b in System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(str))) + { + sb.Append(b.ToString("X2")); + } + return sb.ToString().Trim(); + } + } +} diff --git a/Source/Config/UserInfo.cs b/Source/Config/UserInfo.cs new file mode 100644 index 0000000..719bf2f --- /dev/null +++ b/Source/Config/UserInfo.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LiveTools +{ + public class UserInfo + { + public string NickName { get; set; } = ""; + public string UserId { get; set; } = ""; + public string Pwd { get; set; } = ""; + public string Tokens { get; set; } = ""; + public long OutTime { get; set; } = 0; + public int isOut { get; set; } = 0; + public string OutDateStr { get; set; } = ""; + /// + /// 价格广告 + /// + public string PriceAds { get; set; } = ""; + /// + ///购买联系方式 + /// + public string BuyContact { get; set; } = ""; + public string Setting { get; set; } = ""; + public string Sys_Setting { get; set; } = ""; + public string Parent_Setting { get; set; } = ""; + public string Ads_id { get; set; } = ""; + public string Media_id { get; set; } = ""; + public long LoginTime { get; set; } = 0; + public string Cookie { get; set; } = ""; + } +} diff --git a/Source/Content/CustomWindow.cs b/Source/Content/CustomWindow.cs new file mode 100644 index 0000000..98ef118 --- /dev/null +++ b/Source/Content/CustomWindow.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Interop; +using System.Windows; + +namespace LiveTools +{ + public class CustomWindow : Window + { + public CustomWindow() + { + WindowStyle = WindowStyle.None; + } + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + WindowInteropHelper helper = new WindowInteropHelper(this); + SetWindowLong(helper.Handle, GWL_STYLE, GetWindowLong(helper.Handle, GWL_STYLE) & ~WS_SYSMENU); + } + + internal const int GWL_STYLE = -16; + internal const int WS_SYSMENU = 0x80000; + [DllImport("user32.dll")] + internal static extern int GetWindowLong(IntPtr hwnd, int index); + [DllImport("user32.dll")] + internal static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); + } +} diff --git a/Source/Content/LeftMainContent.xaml b/Source/Content/LeftMainContent.xaml new file mode 100644 index 0000000..9759fcd --- /dev/null +++ b/Source/Content/LeftMainContent.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Content/LeftMainContent.xaml.cs b/Source/Content/LeftMainContent.xaml.cs new file mode 100644 index 0000000..b0ba04e --- /dev/null +++ b/Source/Content/LeftMainContent.xaml.cs @@ -0,0 +1,64 @@ +using CommunityToolkit.Mvvm.Messaging.Messages; +using CommunityToolkit.Mvvm.Messaging; +using HandyControl.Controls; +using HandyControl.Tools.Extension; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using LiveTools.Data; + +namespace LiveTools.Content +{ + /// + /// LeftMainContent.xaml 的交互逻辑 + /// + public partial class LeftMainContent + { + public LeftMainContent() + { + InitializeComponent(); + } + private void ButtonAscending_OnClick(object sender, RoutedEventArgs e) + { + if (sender is ToggleButton button && button.Tag is ItemsControl itemsControl) + { + if (button.IsChecked == true) + { + itemsControl.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); + } + else + { + itemsControl.Items.SortDescriptions.Clear(); + } + } + } + + private void Border_Loaded(object sender, RoutedEventArgs e) + { + WeakReferenceMessenger.Default.Send("login"); + WeakReferenceMessenger.Default.Send(new MsgToken("") { ID = MsgTokenId.Login, From = "LeftMain", Msg = "222" }); + } + + private void ListViewItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + var item= (ListViewItem)sender; + if (item.Tag is string str) + { + WeakReferenceMessenger.Default.Send(str); + } + } + } +} diff --git a/Source/Content/MainContent.xaml b/Source/Content/MainContent.xaml new file mode 100644 index 0000000..ff3f61e --- /dev/null +++ b/Source/Content/MainContent.xaml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/Source/Content/MainContent.xaml.cs b/Source/Content/MainContent.xaml.cs new file mode 100644 index 0000000..6926ebd --- /dev/null +++ b/Source/Content/MainContent.xaml.cs @@ -0,0 +1,97 @@ +using HandyControl.Data; +using System; +using System.Collections.Generic; +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.Navigation; +using System.Windows.Shapes; +using HandyControl.Tools; +using HandyControl.Tools.Extension; +using CommunityToolkit.Mvvm.Messaging; +using CommunityToolkit.Mvvm.Messaging.Messages; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Reflection; +using System.Diagnostics.Eventing.Reader; +using System.Windows.Forms; +namespace LiveTools.Content +{ + /// + /// MainContent.xaml 的交互逻辑 + /// + public partial class MainContent + { + + public MainContent() + { + InitializeComponent(); + WeakReferenceMessenger.Default.Register(this, OnReceive); + } + /// + /// + /// + public object SubContent + { + get;set; + } + private rySafe.UsingLock ui_lock=new rySafe.UsingLock(); + private List list_ui = new List(); + public System.Windows.Controls.UserControl GetUI(Type type) + { + using (ui_lock.Write()) + { + var find = list_ui.FindIndex(x => x.GetType() == type); + if (find == -1) + { + var ctl = (System.Windows.Controls.UserControl)Activator.CreateInstance(type); + list_ui.Add(ctl); + return ctl; + } + else + { + return list_ui[find]; + } + } + } + private void OnReceive(object recipient, string message) + { + if (SubContent is IDisposable disposable) + { + disposable.Dispose(); + } + switch (message) + { + case "login": + if (Config.IsLogin() == 1) + { + SubContent = GetUI(typeof(FrmAccountInfo)); + } + else + { + SubContent = GetUI(typeof(FrmLogin)); + } + break; + case "home": + SubContent = GetUI(typeof(FrmAccountInfo)); + break; + case "rules": + SubContent = GetUI(typeof(FrmRuleView)); + break; + case "direct": + SubContent = GetUI(typeof(FrmDirectView)); + break; + case "setting": + SubContent = GetUI(typeof(FrmSetting)); + break; + } + PresenterMain.Content= SubContent; + } + } +} diff --git a/Source/Content/MainWinContent.xaml b/Source/Content/MainWinContent.xaml new file mode 100644 index 0000000..f93f54f --- /dev/null +++ b/Source/Content/MainWinContent.xaml @@ -0,0 +1,22 @@ + + + + + + +