controlapp/ControlApp/PopUp.cs
Merith-TK 3e31aa0363 Decompile and Rebuild v0.1.2
begin work: base version 0993

move original program for orgnization

golang work

snapshot decompiled code

it builds! (but doesnt run)

source code bump

library stash

decompile 0.1.2, make it build
2025-02-25 21:37:38 -08:00

153 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using AxWMPLib;
namespace ControlApp;
public class PopUp : Form
{
public string run_url;
private Timer tmr;
private const int GWL_STYLE = -20;
private const uint WS_POPUP = 2147483648u;
private const uint WS_CHILD = 536870912u;
private List<string> urls;
private IContainer components;
private AxWindowsMediaPlayer axWindowsMediaPlayer1;
[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 PopUp(string url)
{
urls = new List<string>();
InitializeComponent();
if (ConfigurationManager.AppSettings["Clickthroughpop"] == "True")
{
base.Opacity = 0.5;
uint initialStyle = GetWindowLong(base.Handle, -20);
SetWindowLong(base.Handle, -20, initialStyle | 0x80000 | 0x20);
}
run_url = url;
switch (run_url.Substring(run_url.Length - 3, 3))
{
case "com":
case ".uk":
case "org":
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
Close();
break;
}
tmr = new Timer();
tmr.Tick += popup_tick;
Random rand = new Random();
if (ConfigurationManager.AppSettings["PopSet"] != null && "Long" == ConfigurationManager.AppSettings["PopSet"].ToString())
{
int mins = rand.Next(11);
tmr.Interval = (int)TimeSpan.FromMinutes(mins).TotalMilliseconds;
}
else
{
int mins2 = rand.Next(55) + 5;
tmr.Interval = (int)TimeSpan.FromSeconds(mins2).TotalMilliseconds;
}
}
public void add_url(string url)
{
urls.Add(url);
}
public void popup_tick(object sender, EventArgs e)
{
if (urls.Count > 0)
{
run_url = urls[0];
urls.RemoveAt(0);
axWindowsMediaPlayer1.URL = run_url;
axWindowsMediaPlayer1.Ctlenabled = false;
axWindowsMediaPlayer1.uiMode = "None";
axWindowsMediaPlayer1.settings.autoStart = true;
axWindowsMediaPlayer1.settings.setMode("loop", varfMode: true);
}
else
{
Close();
}
}
private void PopUp_Load(object sender, EventArgs e)
{
Random random = new Random();
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
int screenHeight = Screen.PrimaryScreen.Bounds.Height;
int randomX = random.Next(0, screenWidth - base.Width);
int randomY = random.Next(0, screenHeight - base.Height);
base.StartPosition = FormStartPosition.Manual;
base.Location = new Point(randomX, randomY);
axWindowsMediaPlayer1.URL = run_url;
axWindowsMediaPlayer1.Ctlenabled = false;
axWindowsMediaPlayer1.uiMode = "None";
axWindowsMediaPlayer1.settings.autoStart = true;
axWindowsMediaPlayer1.settings.setMode("loop", varfMode: true);
tmr.Start();
}
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(PopUp));
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
((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.Size = new System.Drawing.Size(800, 450);
this.axWindowsMediaPlayer1.TabIndex = 0;
base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(800, 450);
base.ControlBox = false;
base.Controls.Add(this.axWindowsMediaPlayer1);
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
base.Name = "PopUp";
base.ShowIcon = false;
base.ShowInTaskbar = false;
this.Text = "PopUp";
base.TopMost = true;
base.Load += new System.EventHandler(PopUp_Load);
((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).EndInit();
base.ResumeLayout(false);
}
}