748 lines
36 KiB
C#
748 lines
36 KiB
C#
using Api.Framework;
|
||
using Api.Framework.Cps;
|
||
using Api.Framework.Enums;
|
||
using Api.Framework.Events;
|
||
using DevExpress.XtraEditors;
|
||
using DevExpress.XtraTab;
|
||
using System;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
using UI.Framework.Forms;
|
||
|
||
namespace FLSystem.Forms
|
||
{
|
||
#region xxx
|
||
// public partial class system_douyin_action_control : DevExpress.XtraEditors.XtraUserControl
|
||
// {
|
||
// public system_douyin_action_control()
|
||
// {
|
||
// InitializeComponent();
|
||
// DouyinApi.douyinApiAction = DouyinApiAction;
|
||
// }
|
||
|
||
// private static string DefaultTitle = "抖音扫码登录";
|
||
|
||
|
||
// private void DouyinApiAction(DouyinApi api)
|
||
// {
|
||
// api.IsQualifiedAction = IsQualifiedAction;
|
||
|
||
// bool falg = false;
|
||
// var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
// //判断是否已创建过
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
// {
|
||
// if (page.Text == "抖音活跃列表")
|
||
// {
|
||
// parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// //判断是否已创建过
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// {
|
||
// if (!string.IsNullOrWhiteSpace(api.Member.username) && page.Text.StartsWith(api.Member.username))
|
||
// {
|
||
// xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
// return;
|
||
// }
|
||
// else if (string.IsNullOrWhiteSpace(api.Member.username) && page.Text == DefaultTitle)
|
||
// {
|
||
// falg = true;
|
||
// BaseForm.ShowErrorAutoClose("已经存在扫码登录中的页面");
|
||
// return;
|
||
// }
|
||
// }
|
||
// }));
|
||
|
||
// if (!falg)
|
||
// {
|
||
// var pageName = string.Empty;
|
||
// if (!string.IsNullOrWhiteSpace(api.Member.username))
|
||
// {
|
||
// pageName = $"{api.Member.username}_({api.Member.usernick})";
|
||
// }
|
||
// //AddControlPage(pageName, api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
// AddControlPage(pageName, api.webControl, global::FLSystem.Properties.Resources.抖音);
|
||
// }
|
||
// }
|
||
|
||
// /// <summary>
|
||
// /// 是否满足账号权限
|
||
// /// </summary>
|
||
// /// <param name="flag"></param>
|
||
// private void IsQualifiedAction(DouyinLoginType type, DouyinApi api)
|
||
// {
|
||
// try
|
||
// {
|
||
// switch (type)
|
||
// {
|
||
// case DouyinLoginType.权限不足:
|
||
// {
|
||
// EventClient.OnEvent("", $"{api.Member.username}({api.Member.usernick}) 权限未开通,请开通后重试!");
|
||
// CpsClient.Members.Remove(api.Member);
|
||
// //CpsClient.DelDouyinApi(api.Member.username);
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
// foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
// {
|
||
// if (page.Text == "抖音活跃列表")
|
||
// {
|
||
// parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// ////判断是否已创建过
|
||
// //foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// //{
|
||
// // if (page.Text == DefaultTitle)
|
||
// // {
|
||
// // xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
// // api.chromeBrowser.Load("https://www.douyinec.com/");
|
||
// // return;
|
||
// // }
|
||
// //}
|
||
|
||
// XtraTabPage pageTmp = null;
|
||
|
||
// //判断是否已创建过
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// {
|
||
// if (page.Text == DefaultTitle)
|
||
// {
|
||
// pageTmp = page;
|
||
// }
|
||
// }
|
||
|
||
// if (pageTmp != null)
|
||
// {
|
||
// xtraTabControl1.TabPages.Remove(pageTmp);
|
||
// //AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
// }
|
||
// }));
|
||
// BaseForm.ShowErrorAutoClose($@"该账号未开通商品分享功能,请开通后重试
|
||
|
||
//注:开通电商权限,需要同时满足以下4个条件
|
||
//①、账号实名认证
|
||
//②、个人主页视频数(公开且审核通过)≥ 10 条
|
||
//③、账号粉丝量(绑定第三方粉丝量不计数)≥ 1000
|
||
//④、商品分享保证金 ¥500立即充值", 120);
|
||
// }
|
||
// break;
|
||
// case DouyinLoginType.登录过期:
|
||
// {
|
||
// EventClient.OnEvent("", $"抖音离线:{api.Member.username}({api.Member.usernick})");
|
||
// CpsClient.Members.Remove(api.Member);
|
||
// //CpsClient.DelDouyinApi(api.Member.username);
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
// foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
// {
|
||
// if (page.Text == "抖音活跃列表")
|
||
// {
|
||
// parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// ////判断是否已创建过
|
||
// //foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// //{
|
||
// // if (page.Text == DefaultTitle)
|
||
// // {
|
||
// // xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
// // api.chromeBrowser.Load("https://www.douyinec.com/");
|
||
// // return;
|
||
// // }
|
||
// //}
|
||
|
||
// XtraTabPage pageTmp = null;
|
||
|
||
// //判断是否已创建过
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// {
|
||
// if (page.Text == $"{api.Member.username}_({api.Member.usernick})")
|
||
// {
|
||
// pageTmp = page;
|
||
// }
|
||
// }
|
||
|
||
// if (pageTmp != null)
|
||
// {
|
||
// xtraTabControl1.TabPages.Remove(pageTmp);
|
||
// //AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
// }
|
||
// }));
|
||
// }
|
||
// break;
|
||
// case DouyinLoginType.登录成功:
|
||
// case DouyinLoginType.新号登录成功:
|
||
// {
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// //api.SkipOther("https://buyin.jinritemai.com/dashboard/dataCenter/export-list");
|
||
|
||
// var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
// foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
// {
|
||
// if (page.Text == "抖音活跃列表")
|
||
// {
|
||
// parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// XtraTabPage pageTmp = null;
|
||
|
||
// if (type == DouyinLoginType.新号登录成功)
|
||
// {
|
||
// //判断是否已创建过
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// {
|
||
// if (page.Text == DefaultTitle)
|
||
// {
|
||
// pageTmp = page;
|
||
// }
|
||
// }
|
||
// if (pageTmp != null)
|
||
// {
|
||
// xtraTabControl1.TabPages.Remove(pageTmp);
|
||
// //AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
// AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.webControl, global::FLSystem.Properties.Resources.抖音, true);
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// if (pageTmp == null)
|
||
// {
|
||
// var def = xtraTabControl1.TabPages.FirstOrDefault(f => f.Text == DefaultTitle);
|
||
// var notDef = xtraTabControl1.TabPages.FirstOrDefault(f => f.Text == $"{api.Member.username}_({api.Member.usernick})");
|
||
|
||
// if (def != null)
|
||
// {
|
||
// if (notDef != null)
|
||
// xtraTabControl1.TabPages.Remove(notDef);
|
||
|
||
// def.Text = $"{api.Member.username}_({api.Member.usernick})";
|
||
// //def.Enabled = false;
|
||
// def.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
// }
|
||
// else if (notDef != null && def == null)
|
||
// {
|
||
// notDef.Text = $"{api.Member.username}_({api.Member.usernick})";
|
||
// //notDef.Enabled = false;
|
||
// notDef.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
// }
|
||
// }
|
||
// }
|
||
// }));
|
||
// }
|
||
// break;
|
||
// case DouyinLoginType.删除登录账号:
|
||
// {
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
// foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
// {
|
||
// if (page.Text == "抖音活跃列表")
|
||
// {
|
||
// parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
// break;
|
||
// }
|
||
// }
|
||
// XtraTabPage pageTmp = null;
|
||
|
||
// //判断是否已创建过
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
// {
|
||
// if (page.Text == $"{api.Member.username}_({api.Member.usernick})")
|
||
// {
|
||
// pageTmp = page;
|
||
// }
|
||
// }
|
||
|
||
// if (pageTmp != null)
|
||
// {
|
||
// xtraTabControl1.TabPages.Remove(pageTmp);
|
||
// }
|
||
// }));
|
||
// }
|
||
// break;
|
||
// default:
|
||
// break;
|
||
// }
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// CpsClient.RefreshCps();
|
||
// EventClient.OnEvent(null, MethodType.刷新联盟);
|
||
// }));
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
|
||
// }
|
||
// }
|
||
|
||
// //增加选项夹
|
||
// private void AddControlPage(string pageName, Control control, Image img = null, bool isLoad = false)
|
||
// {
|
||
// this.Invoke(new Action(() =>
|
||
// {
|
||
// try
|
||
// {
|
||
// //增加tabpage
|
||
// XtraTabPage xpage = new XtraTabPage();
|
||
|
||
// if (string.IsNullOrWhiteSpace(pageName))
|
||
// {
|
||
// pageName = DefaultTitle;
|
||
// control.Enabled = true;
|
||
// xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True;
|
||
// }
|
||
// else
|
||
// {
|
||
// //if (isLoad)
|
||
// // control.Enabled = false;
|
||
// xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
// }
|
||
// xpage.Name = pageName;
|
||
// xpage.Text = pageName;
|
||
|
||
// if (img != null)
|
||
// xpage.ImageOptions.Image = img;
|
||
// //if (xpage.Text == "运行日志")
|
||
// //xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
// control.Dock = DockStyle.None;
|
||
// control.Location = new Point(0, 0);
|
||
// control.Size = new Size(1920, 1080);
|
||
|
||
// xpage.Controls.Add(control);//添加要增加的控件
|
||
// xtraTabControl1.TabPages.Add(xpage);
|
||
// xtraTabControl1.SelectedTabPage = xpage;//显示该页
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// if (ex.Message.Contains(@"“CefSharp.Core.Runtime.dll”或它的某一个依赖项"))
|
||
// {
|
||
// EventClient.OnEvent("系统缺少服务", $@"请点击链接,下载组件并安装,安装完成后重启软件
|
||
//下载地址:https://wwa.lanzoui.com/iDDvsroqrxc");
|
||
// try
|
||
// {
|
||
// Clipboard.SetDataObject("https://wwa.lanzoui.com/iDDvsroqrxc" + "?=" + new Random().Next(100, 2000));
|
||
// }
|
||
// catch (Exception)
|
||
// { }
|
||
|
||
// BaseForm.ShowError(@"当前系统缺少组件,请看软件日志,按提示安装相应的组件
|
||
|
||
//下载地址已经复制到粘贴板,在网页中打开即可");
|
||
// }
|
||
// else
|
||
// XtraMessageBox.Show(ex.Message, "AddControlPage Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
// }
|
||
// }));
|
||
// }
|
||
|
||
// private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e)
|
||
// {
|
||
// try
|
||
// {
|
||
// DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs EArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;
|
||
// string name = EArg.Page.Text;//得到关闭的选项卡的text
|
||
// foreach (XtraTabPage page in xtraTabControl1.TabPages)//遍历得到和关闭的选项卡一样的Text
|
||
// {
|
||
// if (page.Text == name)
|
||
// {
|
||
// xtraTabControl1.TabPages.Remove(page);
|
||
|
||
// foreach (Control item in page.Controls)
|
||
// {
|
||
// item.Dispose();
|
||
// }
|
||
// page.Dispose();
|
||
// return;
|
||
// }
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// BaseForm.ShowError(ex);
|
||
// }
|
||
// }
|
||
// }
|
||
#endregion
|
||
public partial class system_douyin_action_control : DevExpress.XtraEditors.XtraUserControl
|
||
{
|
||
public system_douyin_action_control()
|
||
{
|
||
InitializeComponent();
|
||
DouyinApi.douyinApiAction = DouyinApiAction;
|
||
}
|
||
|
||
private static string DefaultTitle = "抖音扫码登录";
|
||
|
||
|
||
private void DouyinApiAction(DouyinApi api)
|
||
{
|
||
api.IsQualifiedAction = IsQualifiedAction;
|
||
|
||
bool falg = false;
|
||
var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
//判断是否已创建过
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
{
|
||
if (page.Text == "抖音活跃列表")
|
||
{
|
||
parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
break;
|
||
}
|
||
}
|
||
|
||
//判断是否已创建过
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(api.Member.username) && page.Text.StartsWith(api.Member.username))
|
||
{
|
||
xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
return;
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(api.Member.username) && page.Text == DefaultTitle)
|
||
{
|
||
falg = true;
|
||
BaseForm.ShowErrorAutoClose("已经存在扫码登录中的页面");
|
||
return;
|
||
}
|
||
}
|
||
}));
|
||
|
||
if (!falg)
|
||
{
|
||
var pageName = string.Empty;
|
||
if (!string.IsNullOrWhiteSpace(api.Member.username))
|
||
{
|
||
pageName = $"{api.Member.username}_({api.Member.usernick})";
|
||
}
|
||
//AddControlPage(pageName, api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
AddControlPage(pageName, api.webControl, global::FLSystem.Properties.Resources.抖音);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否满足账号权限
|
||
/// </summary>
|
||
/// <param name="flag"></param>
|
||
private void IsQualifiedAction(DouyinLoginType type, DouyinApi api)
|
||
{
|
||
try
|
||
{
|
||
switch (type)
|
||
{
|
||
case DouyinLoginType.权限不足:
|
||
{
|
||
EventClient.OnEvent("", $"{api.Member.username}({api.Member.usernick}) 权限未开通,请开通后重试!");
|
||
CpsClient.Members.Remove(api.Member);
|
||
//CpsClient.DelDouyinApi(api.Member.username);
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
{
|
||
if (page.Text == "抖音活跃列表")
|
||
{
|
||
parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
break;
|
||
}
|
||
}
|
||
|
||
////判断是否已创建过
|
||
//foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
//{
|
||
// if (page.Text == DefaultTitle)
|
||
// {
|
||
// xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
// api.chromeBrowser.Load("https://www.douyinec.com/");
|
||
// return;
|
||
// }
|
||
//}
|
||
|
||
XtraTabPage pageTmp = null;
|
||
|
||
//判断是否已创建过
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
{
|
||
if (page.Text == DefaultTitle)
|
||
{
|
||
pageTmp = page;
|
||
}
|
||
}
|
||
|
||
if (pageTmp != null)
|
||
{
|
||
xtraTabControl1.TabPages.Remove(pageTmp);
|
||
//AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
}
|
||
}));
|
||
BaseForm.ShowErrorAutoClose($@"该账号未开通商品分享功能,请开通后重试
|
||
|
||
注:开通电商权限,需要同时满足以下4个条件
|
||
①、账号实名认证
|
||
②、个人主页视频数(公开且审核通过)≥ 10 条
|
||
③、账号粉丝量(绑定第三方粉丝量不计数)≥ 1000
|
||
④、商品分享保证金 ¥500立即充值", 120);
|
||
}
|
||
break;
|
||
case DouyinLoginType.登录过期:
|
||
{
|
||
EventClient.OnEvent("", $"抖音离线:{api.Member.username}({api.Member.usernick})");
|
||
CpsClient.Members.Remove(api.Member);
|
||
//CpsClient.DelDouyinApi(api.Member.username);
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
{
|
||
if (page.Text == "抖音活跃列表")
|
||
{
|
||
parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
break;
|
||
}
|
||
}
|
||
|
||
////判断是否已创建过
|
||
//foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
//{
|
||
// if (page.Text == DefaultTitle)
|
||
// {
|
||
// xtraTabControl1.SelectedTabPage = page;//显示该页
|
||
// api.chromeBrowser.Load("https://www.douyinec.com/");
|
||
// return;
|
||
// }
|
||
//}
|
||
|
||
XtraTabPage pageTmp = null;
|
||
|
||
//判断是否已创建过
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
{
|
||
if (page.Text == $"{api.Member.username}_({api.Member.usernick})")
|
||
{
|
||
pageTmp = page;
|
||
}
|
||
}
|
||
|
||
if (pageTmp != null)
|
||
{
|
||
xtraTabControl1.TabPages.Remove(pageTmp);
|
||
//AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
}
|
||
}));
|
||
}
|
||
break;
|
||
case DouyinLoginType.登录成功:
|
||
case DouyinLoginType.新号登录成功:
|
||
{
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
//api.SkipOther("https://buyin.jinritemai.com/dashboard/dataCenter/export-list");
|
||
|
||
var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
{
|
||
if (page.Text == "抖音活跃列表")
|
||
{
|
||
parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
break;
|
||
}
|
||
}
|
||
|
||
XtraTabPage pageTmp = null;
|
||
|
||
if (type == DouyinLoginType.新号登录成功)
|
||
{
|
||
//判断是否已创建过
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
{
|
||
if (page.Text == DefaultTitle)
|
||
{
|
||
pageTmp = page;
|
||
}
|
||
}
|
||
if (pageTmp != null)
|
||
{
|
||
xtraTabControl1.TabPages.Remove(pageTmp);
|
||
//AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.chromeBrowser, global::FLSystem.Properties.Resources.抖音);
|
||
AddControlPage($"{api.Member.username}_({api.Member.usernick})", api.webControl, global::FLSystem.Properties.Resources.抖音, true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pageTmp == null)
|
||
{
|
||
var def = xtraTabControl1.TabPages.FirstOrDefault(f => f.Text == DefaultTitle);
|
||
var notDef = xtraTabControl1.TabPages.FirstOrDefault(f => f.Text == $"{api.Member.username}_({api.Member.usernick})");
|
||
|
||
if (def != null)
|
||
{
|
||
if (notDef != null)
|
||
xtraTabControl1.TabPages.Remove(notDef);
|
||
|
||
def.Text = $"{api.Member.username}_({api.Member.usernick})";
|
||
//def.Enabled = false;
|
||
def.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
}
|
||
else if (notDef != null && def == null)
|
||
{
|
||
notDef.Text = $"{api.Member.username}_({api.Member.usernick})";
|
||
//notDef.Enabled = false;
|
||
notDef.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
}
|
||
}
|
||
}
|
||
}));
|
||
}
|
||
break;
|
||
case DouyinLoginType.删除登录账号:
|
||
{
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
var parentXtraTabControl = this.Parent.Parent as XtraTabControl;
|
||
foreach (XtraTabPage page in parentXtraTabControl.TabPages)
|
||
{
|
||
if (page.Text == "抖音活跃列表")
|
||
{
|
||
parentXtraTabControl.SelectedTabPage = page;//显示该页
|
||
break;
|
||
}
|
||
}
|
||
XtraTabPage pageTmp = null;
|
||
|
||
//判断是否已创建过
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)
|
||
{
|
||
if (page.Text == $"{api.Member.username}_({api.Member.usernick})")
|
||
{
|
||
pageTmp = page;
|
||
}
|
||
}
|
||
|
||
if (pageTmp != null)
|
||
{
|
||
xtraTabControl1.TabPages.Remove(pageTmp);
|
||
}
|
||
}));
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
CpsClient.RefreshCps();
|
||
EventClient.OnEvent(null, MethodType.刷新联盟);
|
||
}));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
//增加选项夹
|
||
private void AddControlPage(string pageName, Control control, Image img = null, bool isLoad = false)
|
||
{
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
try
|
||
{
|
||
//增加tabpage
|
||
XtraTabPage xpage = new XtraTabPage();
|
||
|
||
if (string.IsNullOrWhiteSpace(pageName))
|
||
{
|
||
pageName = DefaultTitle;
|
||
control.Enabled = true;
|
||
xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True;
|
||
}
|
||
else
|
||
{
|
||
//if (isLoad)
|
||
// control.Enabled = false;
|
||
xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
}
|
||
xpage.Name = pageName;
|
||
xpage.Text = pageName;
|
||
|
||
if (img != null)
|
||
xpage.ImageOptions.Image = img;
|
||
//if (xpage.Text == "运行日志")
|
||
//xpage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;
|
||
control.Dock = DockStyle.None;
|
||
control.Location = new Point(0, 0);
|
||
control.Size = new Size(1920, 1080);
|
||
|
||
xpage.Controls.Add(control);//添加要增加的控件
|
||
xtraTabControl1.TabPages.Add(xpage);
|
||
xtraTabControl1.SelectedTabPage = xpage;//显示该页
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (ex.Message.Contains(@"“CefSharp.Core.Runtime.dll”或它的某一个依赖项"))
|
||
{
|
||
EventClient.OnEvent("系统缺少服务", $@"请点击链接,下载组件并安装,安装完成后重启软件
|
||
下载地址:https://wwa.lanzoui.com/iDDvsroqrxc");
|
||
try
|
||
{
|
||
Clipboard.SetDataObject("https://wwa.lanzoui.com/iDDvsroqrxc" + "?=" + new Random().Next(100, 2000));
|
||
}
|
||
catch (Exception)
|
||
{ }
|
||
|
||
BaseForm.ShowError(@"当前系统缺少组件,请看软件日志,按提示安装相应的组件
|
||
|
||
下载地址已经复制到粘贴板,在网页中打开即可");
|
||
}
|
||
else
|
||
XtraMessageBox.Show(ex.Message, "AddControlPage Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}));
|
||
}
|
||
|
||
private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs EArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;
|
||
string name = EArg.Page.Text;//得到关闭的选项卡的text
|
||
foreach (XtraTabPage page in xtraTabControl1.TabPages)//遍历得到和关闭的选项卡一样的Text
|
||
{
|
||
if (page.Text == name)
|
||
{
|
||
xtraTabControl1.TabPages.Remove(page);
|
||
|
||
foreach (Control item in page.Controls)
|
||
{
|
||
item.Dispose();
|
||
}
|
||
page.Dispose();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
}
|
||
}
|