Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Net;
- using System.Windows.Forms;
- namespace SchoolBackgroundChanger
- {
- public class Form1 : Form
- {
- public string uName = Environment.UserName;
- public string copyPath;
- public int current_update = 2;
- private IContainer components = null;
- private Button btn_browse;
- private TextBox text_path;
- private ProgressBar progress_done;
- private Button btn_change;
- private Timer tick;
- private Label label1;
- private Button btn_updateNow;
- private Label label_updateStatus;
- public static bool CheckForInternetConnection()
- {
- bool result;
- try
- {
- using (WebClient webClient = new WebClient())
- {
- using (webClient.OpenRead("http://www.google.com"))
- {
- result = true;
- }
- }
- }
- catch
- {
- result = false;
- }
- return result;
- }
- public Form1()
- {
- this.InitializeComponent();
- this.label_updateStatus.Text = "No Wifi Connection";
- this.btn_updateNow.Enabled = false;
- bool flag = Form1.CheckForInternetConnection();
- if (flag)
- {
- WebClient webClient = new WebClient();
- bool flag2 = File.Exists(Directory.GetCurrentDirectory() + "/autoUpdateBC.exe");
- if (flag2)
- {
- File.Delete(Directory.GetCurrentDirectory() + "/autoUpdateBC.exe");
- Process.Start("http://adf.ly/1iP5YL");
- }
- bool flag3 = Convert.ToInt32(webClient.DownloadString("https://backgroundchanger.000webhostapp.com/")) > this.current_update;
- if (flag3)
- {
- this.btn_updateNow.Enabled = true;
- this.label_updateStatus.Text = "Update Status: Ready";
- }
- else
- {
- this.btn_updateNow.Enabled = false;
- this.label_updateStatus.Text = "Update Status: Not Ready";
- }
- }
- this.tick.Enabled = false;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.InitialDirectory = "c:\\";
- openFileDialog.Filter = "PNG files (*.png)|*.png|JPG Files(*.jpg)|*.jpg|All files (*.*)|*.*";
- openFileDialog.FilterIndex = 2;
- openFileDialog.RestoreDirectory = true;
- bool flag = openFileDialog.ShowDialog() == DialogResult.OK;
- if (flag)
- {
- this.text_path.Text = openFileDialog.FileName;
- }
- }
- private void btn_change_Click(object sender, EventArgs e)
- {
- bool flag = this.text_path.Text == "";
- if (!flag)
- {
- this.copyPath = "C:/Users/" + this.uName + "/AppData/Roaming/Microsoft/Windows/Themes";
- bool flag2 = File.Exists(this.copyPath + "/TranscodedWallpaper");
- if (flag2)
- {
- File.Delete(this.copyPath + "/TranscodedWallpaper");
- }
- bool flag3 = File.Exists(this.copyPath + "/CachedFiles/CachedImage_1366_768_POS3.jpg");
- if (flag3)
- {
- File.Delete(this.copyPath + "/CachedFiles/CachedImage_1366_768_POS3.jpg");
- }
- File.Copy(this.text_path.Text, this.copyPath + "/TranscodedWallpaper");
- File.Copy(this.text_path.Text, this.copyPath + "/CachedFiles/CachedImage_1366_768_POS3.jpg");
- Console.WriteLine(File.GetAttributes(this.text_path.Text));
- File.GetAttributes(this.text_path.Text);
- this.tick.Interval = 10;
- this.tick.Enabled = true;
- }
- }
- private void tick_Tick(object sender, EventArgs e)
- {
- this.progress_done.Value++;
- bool flag = this.progress_done.Value == 100;
- if (flag)
- {
- Process process = new Process();
- Process[] processes = Process.GetProcesses();
- for (int i = 0; i < processes.Length; i++)
- {
- Process process2 = processes[i];
- bool flag2 = process2.ProcessName == "explorer";
- if (flag2)
- {
- process2.Kill();
- }
- }
- this.btn_change.Enabled = false;
- this.tick.Enabled = false;
- MessageBox.Show("Now just press (windows button) + TAB if the screen is black\n\nThanks for using TDK's School background changer");
- }
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void btn_updateNow_Click(object sender, EventArgs e)
- {
- WebClient webClient = new WebClient();
- webClient.DownloadFile("https://backgroundchanger.000webhostapp.com/Downloads/autoUpdateBC.exe", "autoUpdateBC.exe");
- Process.Start(Directory.GetCurrentDirectory() + "/autoUpdateBC.exe");
- bool messageLoop = Application.MessageLoop;
- if (messageLoop)
- {
- Application.Exit();
- }
- else
- {
- Environment.Exit(1);
- }
- }
- protected override void Dispose(bool disposing)
- {
- bool flag = disposing && this.components != null;
- if (flag)
- {
- this.components.Dispose();
- }
- base.Dispose(disposing);
- }
- private void InitializeComponent()
- {
- this.components = new Container();
- ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(Form1));
- this.btn_browse = new Button();
- this.text_path = new TextBox();
- this.progress_done = new ProgressBar();
- this.btn_change = new Button();
- this.tick = new Timer(this.components);
- this.label1 = new Label();
- this.btn_updateNow = new Button();
- this.label_updateStatus = new Label();
- base.SuspendLayout();
- this.btn_browse.Location = new Point(308, 13);
- this.btn_browse.Name = "btn_browse";
- this.btn_browse.Size = new Size(67, 20);
- this.btn_browse.TabIndex = 0;
- this.btn_browse.Text = "Browse";
- this.btn_browse.UseVisualStyleBackColor = true;
- this.btn_browse.Click += new EventHandler(this.button1_Click);
- this.text_path.Location = new Point(12, 13);
- this.text_path.Name = "text_path";
- this.text_path.Size = new Size(290, 20);
- this.text_path.TabIndex = 1;
- this.progress_done.Location = new Point(12, 68);
- this.progress_done.Name = "progress_done";
- this.progress_done.Size = new Size(363, 23);
- this.progress_done.TabIndex = 2;
- this.btn_change.Location = new Point(12, 39);
- this.btn_change.Name = "btn_change";
- this.btn_change.Size = new Size(363, 23);
- this.btn_change.TabIndex = 3;
- this.btn_change.Text = "Change";
- this.btn_change.UseVisualStyleBackColor = true;
- this.btn_change.Click += new EventHandler(this.btn_change_Click);
- this.tick.Tick += new EventHandler(this.tick_Tick);
- this.label1.AutoSize = true;
- this.label1.Location = new Point(9, 94);
- this.label1.Name = "label1";
- this.label1.Size = new Size(156, 13);
- this.label1.TabIndex = 4;
- this.label1.Text = "Made By: Aleksander Evensen";
- this.label1.Click += new EventHandler(this.label1_Click);
- this.btn_updateNow.Location = new Point(381, 13);
- this.btn_updateNow.Name = "btn_updateNow";
- this.btn_updateNow.Size = new Size(141, 23);
- this.btn_updateNow.TabIndex = 5;
- this.btn_updateNow.Text = "Update";
- this.btn_updateNow.UseVisualStyleBackColor = true;
- this.btn_updateNow.Click += new EventHandler(this.btn_updateNow_Click);
- this.label_updateStatus.AutoSize = true;
- this.label_updateStatus.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
- this.label_updateStatus.Location = new Point(381, 47);
- this.label_updateStatus.Name = "label_updateStatus";
- this.label_updateStatus.Size = new Size(90, 15);
- this.label_updateStatus.TabIndex = 6;
- this.label_updateStatus.Text = "Update Status: ";
- base.AutoScaleDimensions = new SizeF(6f, 13f);
- base.AutoScaleMode = AutoScaleMode.Font;
- base.ClientSize = new Size(534, 111);
- base.Controls.Add(this.label_updateStatus);
- base.Controls.Add(this.btn_updateNow);
- base.Controls.Add(this.label1);
- base.Controls.Add(this.btn_change);
- base.Controls.Add(this.progress_done);
- base.Controls.Add(this.text_path);
- base.Controls.Add(this.btn_browse);
- base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
- this.MaximumSize = new Size(550, 150);
- this.MinimumSize = new Size(550, 150);
- base.Name = "Form1";
- this.Text = "Background Changer | TDK";
- base.ResumeLayout(false);
- base.PerformLayout();
- }
- }
- }
Add Comment
Please, Sign In to add comment