using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Drawing; using System.IO; using System.Linq; using System.Windows.Forms; using AxWMPLib; namespace ControlApp; public class SendOrDelete : Form { private string thefile; private string senderstr; private IContainer components; private AxWindowsMediaPlayer axWindowsMediaPlayer1; private Button Sendbtn; private Button Deletebtn; public SendOrDelete(string senderid) { InitializeComponent(); string location = ConfigurationManager.AppSettings["LocalDrive"]; string[] filetypes = new string[9] { ".jpg", ".jpeg", ".gif", ".mov", ".mpg", ".mpeg", ".avi", ".png", ".mp4" }; List acceptablefiles = new List(); if (location != null) { string[] files = Directory.GetFiles(location); foreach (string file in files) { FileInfo info = new FileInfo(file); if (filetypes.Contains(info.Extension) && info.Length < 1000000) { acceptablefiles.Add(file); } } } int max = acceptablefiles.Count(); if (max > 0) { Random rnd = new Random(); thefile = acceptablefiles[rnd.Next(max)]; senderstr = senderid; } } private void Deletebtn_Click(object sender, EventArgs e) { if (thefile != null) { File.Delete(thefile); } Utils utils = new Utils(); string usrnm = ConfigurationManager.AppSettings["UserName"].ToString(); string line1 = "M=" + usrnm + " chose to delete."; utils.sendcmd(senderstr, utils.Ecrypt(line1), all: false); Close(); } private void SendOrDelete_Load(object sender, EventArgs e) { axWindowsMediaPlayer1.URL = thefile; axWindowsMediaPlayer1.Ctlenabled = false; axWindowsMediaPlayer1.uiMode = "None"; axWindowsMediaPlayer1.settings.autoStart = true; axWindowsMediaPlayer1.settings.setMode("loop", varfMode: true); } private void Sendbtn_Click(object sender, EventArgs e) { Utils utils = new Utils(); if (utils.sendftpfile(thefile)) { string usrnm = ConfigurationManager.AppSettings["UserName"].ToString(); string line1 = "M=" + usrnm + " chose to send."; string line2 = "U=FTP" + Path.GetFileName(thefile); utils.sendcmd(senderstr, utils.Ecrypt(line1) + "|||" + utils.Ecrypt(line2), all: false); } Close(); } 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(SendOrDelete)); this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer(); this.Sendbtn = new System.Windows.Forms.Button(); this.Deletebtn = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).BeginInit(); base.SuspendLayout(); this.axWindowsMediaPlayer1.Dock = System.Windows.Forms.DockStyle.Top; 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 = 1; this.Sendbtn.Location = new System.Drawing.Point(279, 468); this.Sendbtn.Name = "Sendbtn"; this.Sendbtn.Size = new System.Drawing.Size(75, 23); this.Sendbtn.TabIndex = 2; this.Sendbtn.Text = "Send"; this.Sendbtn.UseVisualStyleBackColor = true; this.Sendbtn.Click += new System.EventHandler(Sendbtn_Click); this.Deletebtn.Location = new System.Drawing.Point(384, 468); this.Deletebtn.Name = "Deletebtn"; this.Deletebtn.Size = new System.Drawing.Size(75, 23); this.Deletebtn.TabIndex = 3; this.Deletebtn.Text = "Delete"; this.Deletebtn.UseVisualStyleBackColor = true; this.Deletebtn.Click += new System.EventHandler(Deletebtn_Click); base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f); base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; base.ClientSize = new System.Drawing.Size(800, 503); base.ControlBox = false; base.Controls.Add(this.Deletebtn); base.Controls.Add(this.Sendbtn); base.Controls.Add(this.axWindowsMediaPlayer1); base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; base.Name = "SendOrDelete"; base.ShowIcon = false; base.ShowInTaskbar = false; this.Text = "SendOrDelete"; base.TopMost = true; base.Load += new System.EventHandler(SendOrDelete_Load); ((System.ComponentModel.ISupportInitialize)this.axWindowsMediaPlayer1).EndInit(); base.ResumeLayout(false); } }