Exemplo n.º 1
0
        private void ExitButt_Click(object sender, EventArgs e)
        {
            OMSI omsi = new OMSI()
            {
                Opacity = 0
            };

            omsi.Show();                            //Create and open new Main form of app
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(25);
                Opacity -= 0.1;
            }
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(25);
                omsi.Opacity += 0.1;
            }
            Close();
        }
Exemplo n.º 2
0
        private async void Delete(object sender, EventArgs e)
        {
            await Task.Run(() =>
            {
                if (state == 0)
                {
                    DeleteLbl.Text = "Deleting...";
                    state          = 1;
                    Thread.Sleep(250);
                }
                else if (state == 1)
                {
                    DeleteLbl.Text = "Deleting";
                    state          = 2;
                    Thread.Sleep(250);
                }
                else if (state == 2)
                {
                    DeleteLbl.Text = "Deleting.";
                    state          = 3;
                    Thread.Sleep(250);
                }
                else if (state == 3)
                {
                    DeleteLbl.Text = "Deleting..";
                    state          = 0;
                    Thread.Sleep(250);
                }
            });

            DeletingProgress.Visible = true;
            string[] dirs = Finder.FindDirectoryWhichExists(PATH, DEL_EXT);
            int      size = dirs.Length;

            foreach (string dir in dirs)
            {
                string[] files = Directory.GetFiles(dir);
                DeletingProgress.Maximum = size;
                await Task.Run(() =>
                {
                    foreach (string file in files)
                    {
                        if (Path.GetExtension(file) == DEL_EXT)
                        {
                            File.Delete(file);
                        }
                    }
                    DeletingProgress.Value += 1;
                });
            }
            if (DeletingProgress.Value == size)
            {
                OMSI omsi = new OMSI()
                {
                    Opacity = 0
                };
                omsi.StatusLbl.Text   = "Uninstalling was successful!";
                omsi.StatusPctr.Image = Resources.Success;
                omsi.Show();
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(25);
                    Opacity -= 0.1;
                }
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(25);
                    omsi.Opacity += 0.1;
                }
                Close();
            }
            else
            {
                OMSI omsi = new OMSI()
                {
                    Opacity = 0
                };
                omsi.StatusLbl.Text   = "Something went wrong...";
                omsi.StatusPctr.Image = Resources.Wrong;
                omsi.Show();
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(25);
                    Opacity -= 0.1;
                }
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(25);
                    omsi.Opacity += 0.1;
                }
                Close();
            }
        }
Exemplo n.º 3
0
 private async void Install(object sender, EventArgs e)
 {
     try
     {
         string[]      directories = Finder.FindDirectoryWhichExists(INSTALLING_PATH, BUS_EXT);
         List <string> files       = new List <string>();
         foreach (string toadd in HofInstallList.CheckedItems)
         {
             files.Add($@"{HOF_PATH}\{toadd}");
         }
         int size = directories.Length * files.Count;
         InstallingProgress.Visible = true;
         InstallingProgress.Maximum = size;
         Size = new Size(638, 600);
         foreach (string directory in directories)
         {
             foreach (string file in files)
             {
                 try
                 {
                     await Task.Run(() =>
                     {
                         File.Copy(file, $@"{directory}\{Path.GetFileName(file)}", true);
                         InstallingProgress.Value += 1;
                     });
                 }
                 catch (Exception)
                 {
                     string            title   = "Error!";
                     string            message = "Unknown error";
                     MessageBoxButtons buttons = MessageBoxButtons.OK;
                     MessageBox.Show(message, title, buttons, MessageBoxIcon.Error);
                 }
             }
         }
         if (InstallingProgress.Value == size)
         {
             OMSI omsi = new OMSI()
             {
                 Opacity = 0
             };
             omsi.StatusLbl.Text   = "Installing was successful!";
             omsi.StatusPctr.Image = Resources.Success;
             omsi.Show();
             for (int i = 0; i < 10; i++)
             {
                 Thread.Sleep(25);
                 Opacity -= 0.1;
             }
             for (int i = 0; i < 10; i++)
             {
                 Thread.Sleep(25);
                 omsi.Opacity += 0.1;
             }
             Close();
         }
         else
         {
             OMSI omsi = new OMSI()
             {
                 Opacity = 0
             };
             omsi.StatusLbl.Text   = "Something went wrong...";
             omsi.StatusPctr.Image = Resources.Wrong;
             omsi.Show();
             for (int i = 0; i < 10; i++)
             {
                 Thread.Sleep(25);
                 Opacity -= 0.1;
             }
             for (int i = 0; i < 10; i++)
             {
                 Thread.Sleep(25);
                 omsi.Opacity += 0.1;
             }
             Close();
         }
     }
     catch (Exception)
     {
         string            title   = "Error!";
         string            message = "This application need to exists in root folder of OMSI. Reinstall the OMSI2 Tools or try start this app as administrator.";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(message, title, buttons, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        private async void Reinstall(object sender, EventArgs e)
        {
            try
            {
                string[]      dirs        = Finder.FindDirectoryWhichExists(INSTALLING_PATH, HOF_EXT);
                string[]      directories = Finder.FindDirectoryWhichExists(INSTALLING_PATH, BUS_EXT);
                List <string> files       = new List <string>();
                foreach (string toadd in HofInstallList.CheckedItems)
                {
                    files.Add($@"{HOF_PATH}\{toadd}");
                }
                int size = directories.Length * files.Count + dirs.Length;
                InstallingProgress.Maximum = size;
                Size = new Size(638, 600);
                InstallingProgress.Visible = true;
                //DELETING
                foreach (string dir in dirs)
                {
                    InstallingProgress.Value += 1;
                    string[] filesdel = Directory.GetFiles(dir);
                    Deleting(filesdel);
                }

                //INSTALLING
                Installing(directories, files.ToArray());
                if (InstallingProgress.Value == size)
                {
                    OMSI omsi = new OMSI()
                    {
                        Opacity = 0
                    };
                    omsi.StatusLbl.Text   = "Reinstalling was successful!";
                    omsi.StatusPctr.Image = Resources.Success;
                    omsi.Show();
                    for (int i = 0; i < 10; i++)
                    {
                        Thread.Sleep(25);
                        Opacity -= 0.1;
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        Thread.Sleep(25);
                        omsi.Opacity += 0.1;
                    }
                    Close();
                }
                else
                {
                    OMSI omsi = new OMSI()
                    {
                        Opacity = 0
                    };
                    omsi.StatusLbl.Text   = "Something went wrong...";
                    omsi.StatusPctr.Image = Resources.Wrong;
                    omsi.Show();
                    for (int i = 0; i < 10; i++)
                    {
                        Thread.Sleep(25);
                        Opacity -= 0.1;
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        Thread.Sleep(25);
                        omsi.Opacity += 0.1;
                    }
                    Close();
                }
            }
            catch (Exception ex)
            {
                string            title   = "Error!";
                string            message = "This application need to exists in root folder of OMSI. Reinstall the OMSI2 Tools or try start this app as administrator.";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, title, buttons, MessageBoxIcon.Error);
            }
        }