Advertisement
Guest User

Untitled

a guest
Jul 9th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace Exo_Windows_Backup
  12. {
  13.    
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         public NotifyIcon ni = new NotifyIcon();
  21.         private void button2_Click(object sender, EventArgs e)
  22.         {
  23.             folderBrowserDialog1.ShowDialog();
  24.             textBox1.Text = folderBrowserDialog1.SelectedPath;
  25.         }
  26.  
  27.         private void quitProgramToolStripMenuItem_Click(object sender, EventArgs e)
  28.         {
  29.             Application.Exit();
  30.         }
  31.  
  32.         private void checkBox1_CheckedChanged(object sender, EventArgs e)
  33.         {
  34.             string startupvar = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
  35.  
  36.             if (checkBox1.Checked == true)
  37.             {  
  38.                 //File.Create((Environment.SpecialFolder.ApplicationData + (@"\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" + "\\Exo Windows Backup Autostart.url")));
  39.                 Properties.Settings.Default.autostart = true;
  40.                 Properties.Settings.Default.Save();
  41.                 CreateShortcut(startupvar + (@"\Microsoft\Windows\Start Menu\Programs\Startup" + @"\Exo Windows Backup Autostart.url"), Application.ExecutablePath.ToString());
  42.             }
  43.             else
  44.             {
  45.                 Properties.Settings.Default.autostart = false;
  46.                 Properties.Settings.Default.Save();
  47.                 if (File.Exists(startupvar + (@"\Microsoft\Windows\Start Menu\Programs\Startup" + @"\Exo Windows Backup Autostart.url")))
  48.                 {
  49.                     File.Delete(startupvar + (@"\Microsoft\Windows\Start Menu\Programs\Startup" + @"\Exo Windows Backup Autostart.url"));
  50.                 }
  51.             }
  52.         }
  53.  
  54.         private void checkBox2_CheckedChanged(object sender, EventArgs e)
  55.         {
  56.             if (checkBox2.Checked == true)
  57.             {
  58.                 Properties.Settings.Default.welcomeform = true;
  59.                 Properties.Settings.Default.Save();
  60.             }
  61.             else
  62.             {
  63.                 Properties.Settings.Default.welcomeform = false;
  64.                 Properties.Settings.Default.Save();
  65.             }
  66.         }
  67.  
  68.         private void button1_Click(object sender, EventArgs e)
  69.         {
  70.  
  71.         }
  72.  
  73.         private void button4_Click(object sender, EventArgs e)
  74.         {
  75.             if (checkBox3.Checked == true)
  76.             {
  77.                 Properties.Settings.Default.backuptime = 15;
  78.                 Properties.Settings.Default.Save();
  79.             }
  80.         }
  81.  
  82.         private void button3_Click(object sender, EventArgs e)
  83.         {
  84.             if (radioButton1.Checked == true)
  85.             {
  86.                 Properties.Settings.Default.language = "english";
  87.                 Properties.Settings.Default.Save();
  88.                 MessageBox.Show("A Restart is required. Restart Now!");
  89.                 Application.Restart();
  90.             }
  91.             else if (radioButton2.Checked == true)
  92.             {
  93.                 Properties.Settings.Default.language = "german";
  94.                 Properties.Settings.Default.Save();
  95.                 MessageBox.Show("Ein neustart wird benötigt. Starte jetzt neu!");
  96.                 Application.Restart();
  97.             }
  98.         }
  99.  
  100.         private void CreateShortcut(string shortcutPath, string shortcutDest)
  101.         {
  102.             StreamWriter sw = new StreamWriter(shortcutPath);
  103.             sw.WriteLine("[InternetShortcut]");
  104.  
  105.             sw.WriteLine("URL=file:///" + shortcutDest);
  106.             sw.WriteLine("IconIndex=0");
  107.             sw.Close();
  108.         }
  109.  
  110.         private void Form1_Load(object sender, EventArgs e)
  111.         {
  112.            
  113.             if (Properties.Settings.Default.autofirststart == true)
  114.             {
  115.                 this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
  116.             }
  117.             if (Properties.Settings.Default.autostart == true)
  118.             {
  119.                 radioButton1.Checked = true;
  120.             }
  121.         }
  122.  
  123.         private void Form1_Resize(object sender, EventArgs e)
  124.         {
  125.             if (FormWindowState.Minimized == this.WindowState)
  126.             {
  127.                 ni.Visible = true;
  128.                 ni.ShowBalloonTip(500);
  129.                 this.Hide();
  130.             }
  131.             else if (FormWindowState.Normal == this.WindowState)
  132.             {
  133.                 ni.Visible = false;
  134.             }
  135.         }
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement