Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace aLauncher
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- int lineCount = 0;
- string listLocation = Directory.GetCurrentDirectory() + "/getPrograms.txt";
- private void Form1_Load(object sender, EventArgs e)
- {
- string getLine;
- if (!File.Exists(listLocation))
- {
- File.Create(listLocation);
- MessageBox.Show("File created; please relaunch the program!");
- }
- else
- {
- System.IO.StreamReader theFile = new System.IO.StreamReader(listLocation);
- while ((getLine = theFile.ReadLine()) != null)
- {
- if (File.Exists(getLine.Split('|')[0]))
- {
- Button newButton = new Button();
- newButton.Location = new System.Drawing.Point(12 + ((lineCount + 1) * 55), 12);
- newButton.Height = 40;
- newButton.Width = 40;
- newButton.Name = "Button" + getLine;
- newButton.Image = Icon.ExtractAssociatedIcon(getLine.Split('|')[0]).ToBitmap();
- newButton.Click += new EventHandler(this.launchProgram);
- newButton.MouseHover += new EventHandler(this.showName);
- newButton.MouseLeave += new EventHandler(this.hideName);
- this.Controls.Add(newButton);
- lineCount++;
- }
- }
- }
- }
- private void hideName(object sender, EventArgs e)
- {
- label1.Text = "Launch: ...";
- }
- private void showName(object sender, EventArgs e)
- {
- Button getHover = (Button)sender;
- if (getHover.Name.Contains("config"))
- {
- label1.Text = "Launch: Settings";
- }
- else
- {
- label1.Text = "Launch: " + getHover.Name.Split('|')[1];
- }
- }
- private void launchProgram(object sender, EventArgs e)
- {
- Button getClicked = (Button)sender;
- System.Diagnostics.Process.Start(getClicked.Name.Split('|')[0].Replace("temp", ""));
- this.WindowState = FormWindowState.Minimized;
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- int trueX = Cursor.Position.X - this.Location.X;
- int trueY = Cursor.Position.Y - this.Location.Y;
- if (trueX < this.Width && trueX > (this.Width - 20) && trueY < this.Height && trueY > 0)
- {
- foreach (Control C in this.Controls)
- {
- if (C.Name.Contains("Button"))
- {
- ((Button)C).Location = new Point(((Button)C).Location.X - 3, 12);
- if (((Button)C).Location.X <= 0 - ((Button)C).Width)
- {
- ((Button)C).Location = new Point((((Button)C).Location.X + (lineCount + 1) * 40) + ((lineCount + 1) * 15), 12);
- }
- }
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(listLocation);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment