202 lines
5.3 KiB
C#
202 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
using AxWMPLib;
|
|
using WMPLib;
|
|
|
|
namespace ControlApp;
|
|
|
|
public class SubLoop : Form
|
|
{
|
|
private const int GWL_STYLE = -20;
|
|
|
|
private const uint WS_POPUP = 2147483648u;
|
|
|
|
private const uint WS_CHILD = 536870912u;
|
|
|
|
private Timer tmr;
|
|
|
|
private List<string[]> itemstoloop;
|
|
|
|
private Utils Utils;
|
|
|
|
private string appDirectory;
|
|
|
|
private int position;
|
|
|
|
private IContainer components;
|
|
|
|
private AxWindowsMediaPlayer axWindowsMediaPlayer1;
|
|
|
|
private Label label1;
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
private static extern uint GetWindowLong(nint hWnd, int nIndex);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern int SetWindowLong(nint hWnd, int nIndex, uint dwNewLong);
|
|
|
|
public SubLoop()
|
|
{
|
|
position = 0;
|
|
InitializeComponent();
|
|
label1.Text = "";
|
|
itemstoloop = new List<string[]>();
|
|
Utils = new Utils();
|
|
_ = new string[1];
|
|
appDirectory = AppDomain.CurrentDomain.BaseDirectory + "\\ConstantSubList.txt";
|
|
if (File.Exists(appDirectory))
|
|
{
|
|
string[] array = File.ReadAllLines(appDirectory);
|
|
foreach (string file in array)
|
|
{
|
|
try
|
|
{
|
|
itemstoloop.Add(Utils.seperate_string(file));
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
}
|
|
tmr = new Timer();
|
|
tmr.Tick += loopthrough;
|
|
double time = 0.25;
|
|
tmr.Interval = (int)TimeSpan.FromMinutes(time).TotalMilliseconds;
|
|
uint initialStyle = GetWindowLong(base.Handle, -20);
|
|
SetWindowLong(base.Handle, -20, initialStyle | 0x80000 | 0x20);
|
|
BackColor = Color.Magenta;
|
|
base.TransparencyKey = Color.Magenta;
|
|
tmr.Start();
|
|
}
|
|
|
|
public void loopthrough(object sender, EventArgs e)
|
|
{
|
|
int total = itemstoloop.Count;
|
|
if (position >= total)
|
|
{
|
|
position = 0;
|
|
}
|
|
if (itemstoloop.Count <= 0 || (axWindowsMediaPlayer1.playState != WMPPlayState.wmppsStopped && axWindowsMediaPlayer1.playState != 0))
|
|
{
|
|
return;
|
|
}
|
|
string[] item = itemstoloop[position];
|
|
bool mess = true;
|
|
try
|
|
{
|
|
if (item[0] == "m")
|
|
{
|
|
mess = false;
|
|
}
|
|
doitem(item[1], mess);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
position++;
|
|
}
|
|
|
|
public void additem(string item)
|
|
{
|
|
if (!Utils.IsWebPage(item))
|
|
{
|
|
itemstoloop.Add(new string[2] { "t", item });
|
|
return;
|
|
}
|
|
item = Utils.Get_File(item);
|
|
if (item != "FAILED")
|
|
{
|
|
itemstoloop.Add(new string[2] { "m", item });
|
|
}
|
|
}
|
|
|
|
public void doitem(string item, bool message)
|
|
{
|
|
if (message)
|
|
{
|
|
label1.Visible = true;
|
|
label1.Text = item;
|
|
axWindowsMediaPlayer1.Visible = false;
|
|
return;
|
|
}
|
|
label1.Visible = false;
|
|
axWindowsMediaPlayer1.Visible = true;
|
|
axWindowsMediaPlayer1.URL = item;
|
|
axWindowsMediaPlayer1.Ctlenabled = false;
|
|
axWindowsMediaPlayer1.stretchToFit = true;
|
|
axWindowsMediaPlayer1.uiMode = "None";
|
|
axWindowsMediaPlayer1.settings.autoStart = true;
|
|
axWindowsMediaPlayer1.settings.volume = 25;
|
|
}
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
File.Delete(appDirectory);
|
|
using (StreamWriter writer = File.AppendText(appDirectory))
|
|
{
|
|
foreach (string[] items in itemstoloop)
|
|
{
|
|
writer.WriteLine("[" + items[0] + "],[" + items[1] + "]");
|
|
}
|
|
}
|
|
tmr.Stop();
|
|
}
|
|
|
|
private void SubLoop_Load(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SubLoop));
|
|
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
|
|
this.label1 = new System.Windows.Forms.Label();
|
|
((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).BeginInit();
|
|
base.SuspendLayout();
|
|
this.axWindowsMediaPlayer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.axWindowsMediaPlayer1.Enabled = true;
|
|
this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(0, 0);
|
|
this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
|
|
this.axWindowsMediaPlayer1.OcxState = (System.Windows.Forms.AxHost.State)resources.GetObject("axWindowsMediaPlayer1.OcxState");
|
|
this.axWindowsMediaPlayer1.TabIndex = 0;
|
|
this.label1.BackColor = System.Drawing.Color.Transparent;
|
|
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.label1.Font = new System.Drawing.Font("Arial", 60f);
|
|
this.label1.Location = new System.Drawing.Point(0, 0);
|
|
this.label1.Name = "label1";
|
|
this.label1.Size = new System.Drawing.Size(800, 450);
|
|
this.label1.TabIndex = 1;
|
|
this.label1.Text = "label1";
|
|
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
base.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
base.Location = new System.Drawing.Point(0, 0);
|
|
base.TopMost = true;
|
|
base.Visible = true;
|
|
base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f);
|
|
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
this.BackColor = System.Drawing.Color.White;
|
|
base.Controls.Add(this.label1);
|
|
base.Controls.Add(this.axWindowsMediaPlayer1);
|
|
base.Name = "SubLoop";
|
|
base.Opacity = 0.05;
|
|
this.Text = "SubLoop";
|
|
base.Load += new System.EventHandler(SubLoop_Load);
|
|
((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).EndInit();
|
|
base.ResumeLayout(false);
|
|
}
|
|
}
|