Example #1
0
        private void pathTextBox_TextChanged(object sender, EventArgs e)
        {
            loadProjectBtn.Enabled = false;
            projectName.Text       = translations.StartupForm_pathTextBox_TextChanged_None;
            projectVersion.Text    = translations.StartupForm_pathTextBox_TextChanged_None;

            if (GeneralFunctions.IsValidExtremeProject(pathTextBox.PathText.Text))
            {
                Program.MainForm.CurrentProject.ProjectPath = pathTextBox.PathText.Text;
                Program.MainForm.CurrentProject.ReadInfo();
                projectName.Text = Program.MainForm.CurrentProject.ProjectName;

                string projVersion = Convert.ToString(Program.MainForm.CurrentProject.ProjectVersion);
                string progVersion = Convert.ToString(_versionHandler.CurrentVersion);

                VersionReader.CompareVersionResult versionCompare =
                    VersionReader.CompareVersions(projVersion, progVersion);
                if (versionCompare == VersionReader.CompareVersionResult.VersionSame)
                {
                    projectVersion.Text    = translations.StartupForm_pathTextBox_TextChanged_ProjectVersionSame;
                    loadProjectBtn.Enabled = true;
                }
                else if (versionCompare == VersionReader.CompareVersionResult.VersionNew)
                {
                    projectVersion.Text    = translations.StartupForm_pathTextBox_TextChanged_ProjectVersionOlder;
                    loadProjectBtn.Enabled = true;
                }
                else if (versionCompare == VersionReader.CompareVersionResult.VersionOld)
                {
                    projectVersion.Text = translations.StartupForm_pathTextBox_TextChanged_ProjectVersionNewer;
                }
            }
            else
            {
                MessageBox.Show(Convert.ToString(translations.StartupForm_pathTextBox_TextChanged_InvalidESPrj));
            }
        }
Example #2
0
        private async void StartupForm_Load(object sender, EventArgs e)
        {
            //Download SAMPCTL
            await SampCtl.EnsureLatestInstalled(Application.StartupPath);

            //Add event.
            pathTextBox.PathText.TextChanged += pathTextBox_TextChanged;

            //Check for updates
            AutoUpdater.ParseUpdateInfoEvent += AutoUpdater_ParseUpdateInfoEvent;
            DownloadForm.DownloadFile(translations.StartupForm_StartupForm_Load_Checking_for_updates, "https://api.github.com/repos/Ahmad45123/ExtremeStudio/releases/latest", Application.StartupPath + "/latest.txt");
            AutoUpdater.Start(Application.StartupPath + "/latest.txt");

            //If the interop files don't exist, Extract the files.

            /*if (IsFirst &&
             *  (!File.Exists(
             *       Application.StartupPath + "/x64/SQLite.Interop.dll") ||
             *   !File.Exists(
             *       Application.StartupPath + "/x86/SQLite.Interop.dll")))
             * {
             *  //Remove old.
             *  if (File.Exists(
             *      Application.StartupPath + "/x64/SQLite.Interop.dll"))
             *  {
             *      File.Delete(
             *          Application.StartupPath + "/x64/SQLite.Interop.dll");
             *  }
             *
             *  if (File.Exists(
             *      Application.StartupPath + "/x86/SQLite.Interop.dll"))
             *  {
             *      File.Delete(
             *          Application.StartupPath + "/x86/SQLite.Interop.dll");
             *  }
             *
             *  //Extract New
             *  File.WriteAllBytes(
             *      Application.StartupPath + "/interop.zip", Properties.Resources.SQLite_Interop); //Write the file.
             *  GeneralFunctions.FastZipUnpack(Application.StartupPath + "/interop.zip",
             *      Application.StartupPath); //Extract it.
             *  File.Delete(
             *      Application.StartupPath + "/interop.zip"); //Delete the temp file.
             * }*/

            //Create needed folders and files.
            if (!Directory.Exists(
                    Application.StartupPath + "/cache"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/cache/serverPackages"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache/serverPackages");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/cache/includes"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache/includes");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/configs"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/configs");
                File.WriteAllText(
                    Application.StartupPath + "/configs/recent.json", "");
            }

            //Setting the IsGlobal in Settings will make sure the settings are in place and correct.
            Program.SettingsForm.IsGlobal = true;

            //Load all the recent.
            if (File.Exists(
                    Application.StartupPath + "/configs/recent.json"))
            {
                try
                {
                    Recent = JsonConvert.DeserializeObject <List <string> >(
                        File.ReadAllText(
                            Application.StartupPath + "/configs/recent.json"));
                    if (ReferenceEquals(Recent, null))
                    {
                        Recent = new List <string>();
                    }
                }
                catch (Exception)
                {
                }
            }

            if (ProjectToOpen != "")
            {
                if (GeneralFunctions.IsValidExtremeProject(ProjectToOpen))
                {
                    Program.MainForm.CurrentProject.ProjectPath = ProjectToOpen;
                    Program.MainForm.CurrentProject.ReadInfo();
                    projectName.Text = Program.MainForm.CurrentProject.ProjectName;

                    string projVersion = Convert.ToString(Program.MainForm.CurrentProject.ProjectVersion);
                    string progVersion = Convert.ToString(_versionHandler.CurrentVersion);

                    VersionReader.CompareVersionResult versionCompare =
                        VersionReader.CompareVersions(projVersion, progVersion);
                    if (versionCompare == VersionReader.CompareVersionResult.VersionSame)
                    {
                        loadProjectBtn_Click(null, EventArgs.Empty);
                    }
                    else if (versionCompare == VersionReader.CompareVersionResult.VersionNew)
                    {
                        loadProjectBtn_Click(null, EventArgs.Empty);
                    }
                    else if (versionCompare == VersionReader.CompareVersionResult.VersionOld)
                    {
                        MessageBox.Show(translations.StartupForm_pathTextBox_TextChanged_ProjectVersionNewer);
                        Application.Exit();
                    }
                }
                else
                {
                    MessageBox.Show(Convert.ToString(translations.StartupForm_pathTextBox_TextChanged_InvalidESPrj));
                    Application.Exit();
                }
            }
        }