322 lines
8.1 KiB
C#
322 lines
8.1 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
using AxWMPLib;
|
|
using Microsoft.Web.WebView2.WinForms;
|
|
|
|
namespace ControlApp;
|
|
|
|
public class WatchForMe : Form
|
|
{
|
|
private string senderstr;
|
|
|
|
private string pub_Url;
|
|
|
|
private const int INTERNET_OPTION_USER_AGENT = 41;
|
|
|
|
private Utils u;
|
|
|
|
private DirectoryInfo vlcdir;
|
|
|
|
private int timewatched;
|
|
|
|
private int timecensored;
|
|
|
|
private bool isdeactive;
|
|
|
|
private int losefocus;
|
|
|
|
private bool censored;
|
|
|
|
private IContainer components;
|
|
|
|
private Timer WatchTime;
|
|
|
|
private Timer CensorTime;
|
|
|
|
private WebView2 webView21;
|
|
|
|
private TextBox textBox1;
|
|
|
|
private AxWindowsMediaPlayer axWindowsMediaPlayer1;
|
|
|
|
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
public static extern bool InternetSetOption(nint hInternet, int dwOption, string lpBuffer, int lpdwBufferLength);
|
|
|
|
private void SetUserAgent(string userAgent)
|
|
{
|
|
InternetSetOption(IntPtr.Zero, 41, userAgent, userAgent.Length);
|
|
}
|
|
|
|
private static bool IsWebPage(string input)
|
|
{
|
|
if (Uri.TryCreate(input, UriKind.Absolute, out Uri uriResult))
|
|
{
|
|
if (!(uriResult.Scheme == Uri.UriSchemeHttp))
|
|
{
|
|
return uriResult.Scheme == Uri.UriSchemeHttps;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public WatchForMe(string Url, string senderid)
|
|
{
|
|
u = new Utils();
|
|
senderstr = senderid;
|
|
SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0");
|
|
vlcdir = new DirectoryInfo("C:\\Program Files\\VideoLAN\\VLC");
|
|
InitializeComponent();
|
|
textBox1.Focus();
|
|
switch (Path.GetExtension(Url))
|
|
{
|
|
case ".mp4":
|
|
case ".webm":
|
|
case ".webp":
|
|
case ".gif":
|
|
pub_Url = Url;
|
|
axWindowsMediaPlayer1.Ctlenabled = false;
|
|
axWindowsMediaPlayer1.uiMode = "None";
|
|
axWindowsMediaPlayer1.settings.autoStart = true;
|
|
axWindowsMediaPlayer1.settings.setMode("loop", varfMode: true);
|
|
if (IsWebPage(Url))
|
|
{
|
|
if (u.Get_File(Url) != "FAILED")
|
|
{
|
|
FileInfo fileInfo = new FileInfo(Url);
|
|
axWindowsMediaPlayer1.URL = fileInfo.ToString();
|
|
}
|
|
else
|
|
{
|
|
axWindowsMediaPlayer1.URL = Url;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FileInfo fileInfo2 = new FileInfo(Url);
|
|
axWindowsMediaPlayer1.URL = fileInfo2.ToString();
|
|
}
|
|
webView21.Visible = false;
|
|
break;
|
|
case ".png":
|
|
case ".jpg":
|
|
case ".jepg":
|
|
{
|
|
string file = "";
|
|
webView21.Visible = false;
|
|
file = u.Get_File(Url);
|
|
if (file == "FAILED")
|
|
{
|
|
Close();
|
|
break;
|
|
}
|
|
Image i = Image.FromFile(file);
|
|
Screen my = Screen.AllScreens[0];
|
|
if (i.Width > my.Bounds.Width)
|
|
{
|
|
base.Width = my.Bounds.Width;
|
|
}
|
|
else
|
|
{
|
|
base.Width = i.Width;
|
|
}
|
|
if (i.Height > my.Bounds.Height)
|
|
{
|
|
base.Height = my.Bounds.Height;
|
|
}
|
|
else
|
|
{
|
|
base.Height = i.Height;
|
|
}
|
|
axWindowsMediaPlayer1.Visible = false;
|
|
PictureBox pictureBox = new PictureBox
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
Image = i
|
|
};
|
|
base.Controls.Add(pictureBox);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
axWindowsMediaPlayer1.Visible = false;
|
|
if (Url.Substring(0, 4).ToUpper() != "HTTP")
|
|
{
|
|
Url = "http://" + Url;
|
|
}
|
|
Uri uri = new Uri(Url);
|
|
webView21.Source = uri;
|
|
break;
|
|
}
|
|
}
|
|
AutoSize = true;
|
|
timewatched = 0;
|
|
timecensored = 0;
|
|
losefocus = 0;
|
|
WatchTime.Interval = 1000;
|
|
WatchTime.Tick += Timer1_Tick;
|
|
WatchTime.Start();
|
|
CensorTime.Interval = 1000;
|
|
CensorTime.Tick += Censored_Tick;
|
|
isdeactive = false;
|
|
base.Deactivate += Form1_Deactivate;
|
|
base.Activated += Form1_Reactivate;
|
|
base.FormClosing += Form1_FormClosing;
|
|
textBox1.SendToBack();
|
|
}
|
|
|
|
private void WatchForMe_Load(object sender, EventArgs e)
|
|
{
|
|
censored = false;
|
|
}
|
|
|
|
private void Censored_Tick(object sender, EventArgs e)
|
|
{
|
|
timecensored++;
|
|
}
|
|
|
|
private void Timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
if (!isdeactive)
|
|
{
|
|
textBox1.Focus();
|
|
timewatched++;
|
|
Text = "Watch for me Time=" + timewatched + ": Censored for=" + timecensored + ": Lost focus=" + losefocus;
|
|
}
|
|
}
|
|
|
|
private void Form1_Deactivate(object sender, EventArgs e)
|
|
{
|
|
losefocus++;
|
|
isdeactive = true;
|
|
}
|
|
|
|
private void Form1_Reactivate(object sender, EventArgs e)
|
|
{
|
|
if (isdeactive)
|
|
{
|
|
isdeactive = false;
|
|
}
|
|
}
|
|
|
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (e.CloseReason == CloseReason.UserClosing)
|
|
{
|
|
string usrnm = ConfigurationManager.AppSettings["UserName"].ToString();
|
|
Utils utils = new Utils();
|
|
utils.sendcmd(senderstr, utils.Ecrypt("M=User : " + usrnm + " Watched for : " + timewatched + " seconds. Censored for : " + timecensored + ". Form lost focus :" + losefocus + " times"), all: false);
|
|
}
|
|
}
|
|
|
|
public void dokeys()
|
|
{
|
|
}
|
|
|
|
private void WFM_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.C)
|
|
{
|
|
if (censored)
|
|
{
|
|
base.Opacity = 1.0;
|
|
censored = false;
|
|
CensorTime.Stop();
|
|
}
|
|
else
|
|
{
|
|
base.Opacity = 0.0;
|
|
censored = true;
|
|
CensorTime.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar == 'c')
|
|
{
|
|
if (censored)
|
|
{
|
|
base.Opacity = 1.0;
|
|
censored = false;
|
|
CensorTime.Stop();
|
|
}
|
|
else
|
|
{
|
|
base.Opacity = 0.0;
|
|
censored = true;
|
|
CensorTime.Start();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
this.components = new System.ComponentModel.Container();
|
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WatchForMe));
|
|
this.WatchTime = new System.Windows.Forms.Timer(this.components);
|
|
this.CensorTime = new System.Windows.Forms.Timer(this.components);
|
|
this.webView21 = new Microsoft.Web.WebView2.WinForms.WebView2();
|
|
this.textBox1 = new System.Windows.Forms.TextBox();
|
|
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
|
|
((System.ComponentModel.ISupportInitialize)this.webView21).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).BeginInit();
|
|
base.SuspendLayout();
|
|
this.webView21.AllowExternalDrop = true;
|
|
this.webView21.CreationProperties = null;
|
|
this.webView21.DefaultBackgroundColor = System.Drawing.Color.White;
|
|
this.webView21.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.webView21.Location = new System.Drawing.Point(0, 0);
|
|
this.webView21.Name = "webView21";
|
|
this.webView21.Size = new System.Drawing.Size(1044, 647);
|
|
this.webView21.TabIndex = 1;
|
|
this.webView21.ZoomFactor = 1.0;
|
|
this.textBox1.Location = new System.Drawing.Point(224, 368);
|
|
this.textBox1.Name = "textBox1";
|
|
this.textBox1.Size = new System.Drawing.Size(100, 23);
|
|
this.textBox1.TabIndex = 2;
|
|
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(TextBox1_KeyPress);
|
|
this.textBox1.LostFocus += new System.EventHandler(TextBox1_LostFocus);
|
|
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.Size = new System.Drawing.Size(1044, 647);
|
|
this.axWindowsMediaPlayer1.TabIndex = 3;
|
|
base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f);
|
|
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
base.ClientSize = new System.Drawing.Size(1044, 647);
|
|
base.Controls.Add(this.axWindowsMediaPlayer1);
|
|
base.Controls.Add(this.textBox1);
|
|
base.Controls.Add(this.webView21);
|
|
base.Name = "WatchForMe";
|
|
this.Text = "WatchForMe";
|
|
base.Load += new System.EventHandler(WatchForMe_Load);
|
|
base.KeyDown += new System.Windows.Forms.KeyEventHandler(WFM_KeyDown);
|
|
((System.ComponentModel.ISupportInitialize)this.webView21).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).EndInit();
|
|
base.ResumeLayout(false);
|
|
base.PerformLayout();
|
|
}
|
|
|
|
private void TextBox1_LostFocus(object sender, EventArgs e)
|
|
{
|
|
textBox1.Focus();
|
|
}
|
|
}
|