Пример #1
0
        public void DownloadGame(ModStoreGame game)
        {
            try
            {
                var installedGame = GetInstalledModule(game);
                //If game is installed remove it
                if (installedGame != null)
                {
                    InstalledItems.Remove(installedGame);
                }

                string tempFileName = Path.GetTempPath() + game.Path.Substring(game.Path.LastIndexOf("/") + 1);

                if (DownloadFile(game.Path, tempFileName).Start() == Tasker.Conclusion.Success)
                {
                    MainForm.StaticRef.AddGames(new string[] { tempFileName });
                    File.Delete(tempFileName);
                }

                //InstalledItems.Add(game.CreateInstalledItem());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Critical error: " + ex.Message + ex.StackTrace, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            SaveConfig();
        }
Пример #2
0
        public void DownloadGame(ModStoreGame game)
        {
            try
            {
                var installedGame = GetInstalledModule(game);
                //If game is installed remove it
                if (installedGame != null)
                {
                    InstalledItems.Remove(installedGame);
                }

                string tempFileName = Path.GetTempPath() + game.Path.Substring(game.Path.LastIndexOf("/") + 1);
                if (!ProgressBarForm.DownloadFile(game.Path, tempFileName))
                {
                    throw new Exception("Cannot download file: " + game.Path);
                }

                MainForm mainForm = Application.OpenForms[0] as MainForm;
                mainForm.AddGames(new string[] { tempFileName });
                File.Delete(tempFileName);

                //InstalledItems.Add(game.CreateInstalledItem());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Critical error: " + ex.Message + ex.StackTrace, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            SaveConfig();
        }