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 gLauncher_v2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- int lineCount = 0;
- string listLocation = Directory.GetCurrentDirectory() + "/gamePaths.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!", "gLauncher v2");
- }
- 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 * 62), 15);
- newButton.Height = 50;
- newButton.Width = 50;
- newButton.Name = lineCount + "|" + 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 moveButtons_Tick(object sender, EventArgs e)
- {
- int trueX = this.Location.X - Cursor.Position.X;
- int trueY = this.Location.Y - Cursor.Position.Y;
- foreach (Control C in this.Controls)
- {
- if (C.Name.Contains("|") && trueY > -100 && trueY < -40 && trueX < 0 && trueX > -(this.Width))
- {
- int theValue = (trueX + this.Width) - (lineCount * 65 / 2);
- ((Button)C).Left = theValue + (65 * Convert.ToInt16(((Button)C).Name.Split('|')[0]));
- }
- }
- }
- 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('|')[2];
- }
- }
- private void launchProgram(object sender, EventArgs e)
- {
- Button getClicked = (Button)sender;
- System.Diagnostics.Process.Start(getClicked.Name.Split('|')[1]);
- this.WindowState = FormWindowState.Minimized;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment