Ejemplo n.º 1
0
        private async Task Initialize()
        {
            string     dataSource = Path.Combine(LauncherPath.GetDataDirectory(), DbDataSourceAdapter.DatabaseFileName);
            DataAccess access     = new DataAccess(new SqliteDatabaseAdapter(), DbDataSourceAdapter.CreateConnectionString(dataSource));

            m_versionHandler = new VersionHandler(access, DbDataSourceAdapter.CreateAdapter(true), AppConfiguration);

            if (m_versionHandler.UpdateRequired())
            {
                m_versionHandler.UpdateProgress += handler_UpdateProgress;

                m_progressBarUpdate = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
                ProgressBarStart(m_progressBarUpdate);

                await Task.Run(() => ExecuteVersionUpdate());

                ProgressBarEnd(m_progressBarUpdate);

                AppConfiguration.Refresh(); //We have to refresh here because a column may have been added to the Configuration table
            }

            if (AppConfiguration.CleanTemp)
            {
                CleanTempDirectory();
            }

            DirectoryDataSourceAdapter = new DirectoryDataSourceAdapter(AppConfiguration.GameFileDirectory);
            DataCache.Instance.Init(DataSourceAdapter);
            DataCache.Instance.AppConfiguration.GameFileViewTypeChanged += AppConfiguration_GameFileViewTypeChanged;
            DataCache.Instance.TagMapLookup.TagMappingChanged           += TagMapLookup_TagMappingChanged;
            DataCache.Instance.TagsChanged += DataCache_TagsChanged;

            SetupTabs();
            RebuildUtilityToolStrip();
            BuildUtilityToolStrip();

            InitTagSelectControl();
            InitDownloadView();

            ctrlAssociationView.Initialize(DataSourceAdapter, AppConfiguration);
            ctrlAssociationView.FileDeleted        += ctrlAssociationView_FileDeleted;
            ctrlAssociationView.FileOrderChanged   += ctrlAssociationView_FileOrderChanged;
            ctrlAssociationView.RequestScreenshots += CtrlAssociationView_RequestScreenshots;
        }
Ejemplo n.º 2
0
        private async Task HandleSyncStatusLibraryOptions(SyncFileOption option, IEnumerable <string> files)
        {
            ProgressBarForm form = new ProgressBarForm();

            form.ProgressBarStyle = ProgressBarStyle.Marquee;

            switch (option)
            {
            case SyncFileOption.Add:
                form.DisplayText = "Searching...";
                ProgressBarStart(form);

                List <IGameFile> gameFiles = await Task.Run(() => FindIdGamesFiles(files));

                foreach (IGameFile gameFile in gameFiles)
                {
                    m_downloadHandler.Download(IdGamesDataSourceAdapter, gameFile as IGameFileDownloadable);
                }

                ProgressBarEnd(form);
                DisplayFilesNotFound(files, gameFiles);

                if (gameFiles.Count > 0)
                {
                    DisplayDownloads();
                }

                break;

            case SyncFileOption.Delete:
                form.DisplayText = "Deleting...";
                ProgressBarStart(form);

                await Task.Run(() => DeleteLibraryGameFiles(files));

                ProgressBarEnd(form);
                UpdateLocal();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        private async void updateMetadataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IdGamesDataAdapater adapter = new IdGamesDataAdapater(AppConfiguration.IdGamesUrl, AppConfiguration.ApiPage, AppConfiguration.MirrorUrl);

            IGameFile[] localFiles = SelectedItems(GetCurrentViewControl());

            if (localFiles.Length > 0)
            {
                bool showForm = true, showError = true, updateView = false;
                m_cancelMetaUpdate = false;
                DialogResult    result   = DialogResult.Cancel;
                MetaDataForm    form     = CreateMetaForm();
                ProgressBarForm progress = InitMetaProgressBar();

                foreach (IGameFile localFile in localFiles)
                {
                    try
                    {
                        Enabled = false;
                        progress.DisplayText = string.Format("Searching for {0}...", localFile.FileNameNoPath);
                        progress.Show(this);

                        IEnumerable <IGameFile> remoteFiles = await Task.Run(() => GetMetaFiles(adapter, localFile.FileNameNoPath));

                        Enabled = true;
                        progress.Hide();

                        if (remoteFiles == null || m_cancelMetaUpdate)
                        {
                            break;
                        }

                        if (!remoteFiles.Any())
                        {
                            if (showError)
                            {
                                showError = HandleMetaError(localFile);
                            }
                        }
                        else
                        {
                            IGameFile remoteFile = HandleMultipleMetaFilesFound(localFile, remoteFiles);

                            if (remoteFile != null)
                            {
                                form.GameFileEdit.SetDataSource(remoteFile, new ITagData[] { });

                                if (showForm) //OK = Accept current file, Yes = Accept All files
                                {
                                    result = form.ShowDialog(this);
                                }

                                if (result != DialogResult.Cancel)
                                {
                                    List <GameFileFieldType> fields = form.GameFileEdit.UpdateDataSource(localFile);
                                    showForm = (result == DialogResult.OK);

                                    if (fields.Count > 0)
                                    {
                                        updateView = HandleUpdateMetaFields(localFile, fields);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        Enabled = true;
                        progress.Hide();

                        MessageBox.Show(this, "Failed to fetch metadata from the id games mirror.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break; //not expected, break from loop
                    }
                }

                if (updateView)
                {
                    HandleSelectionChange(GetCurrentViewControl(), true);
                }
            }
        }
Ejemplo n.º 4
0
        private async void Initialize()
        {
            string     dataSource = Path.Combine(Directory.GetCurrentDirectory(), DbDataSourceAdapter.GetDatabaseFileName());
            DataAccess access     = new DataAccess(new SqliteDatabaseAdapter(), DbDataSourceAdapter.CreateConnectionString(dataSource));

            m_versionHandler = new VersionHandler(access, DataSourceAdapter, AppConfiguration);

            if (m_versionHandler.UpdateRequired())
            {
                m_versionHandler.UpdateProgress += handler_UpdateProgress;

                m_progressBarUpdate = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
                ProgressBarStart(m_progressBarUpdate);

                await Task.Run(() => ExecuteVersionUpdate());

                ProgressBarEnd(m_progressBarUpdate);

                AppConfiguration.Refresh(); //We have to refresh here because a column may have been added to the Configuration table
            }

            try
            {
                //Only set location and window state if the location is valid, either way we always set Width, Height, and splitter values
                if (ValidatePosition(AppConfiguration))
                {
                    StartPosition = FormStartPosition.Manual;
                    Location      = new Point(AppConfiguration.AppX, AppConfiguration.AppY);

                    WindowState = AppConfiguration.WindowState;
                }

                Width  = AppConfiguration.AppWidth;
                Height = AppConfiguration.AppHeight;

                splitTopBottom.SplitterDistance = AppConfiguration.SplitTopBottom;
                splitLeftRight.SplitterDistance = AppConfiguration.SplitLeftRight;
            }
            catch (DirectoryNotFoundException ex)
            {
                MessageBox.Show(this, string.Format("The directory specified in your settings was incorrect: '{0}'", ex.Message),
                                "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tblMain.Enabled = false;
                return;
            }

            if (AppConfiguration.CleanTemp)
            {
                CleanTempDirectory();
            }

            DirectoryDataSourceAdapter = new DirectoryDataSourceAdapter(AppConfiguration.GameFileDirectory);
            SetupTabs();
            RebuildTagToolStrip();
            RebuildUtilityToolStrip();

            m_downloadView           = new DownloadView();
            m_downloadView.UserPlay += DownloadView_UserPlay;
            m_downloadHandler        = new DownloadHandler(AppConfiguration.TempDirectory, m_downloadView);

            ctrlAssociationView.Initialize(DataSourceAdapter, AppConfiguration);
            ctrlAssociationView.FileDeleted        += ctrlAssociationView_FileDeleted;
            ctrlAssociationView.FileOrderChanged   += ctrlAssociationView_FileOrderChanged;
            ctrlAssociationView.RequestScreenshots += CtrlAssociationView_RequestScreenshots;

            m_splash.Close();

            await CheckFirstInit();

            UpdateLocal();

            SetupSearchFilters();
            HandleTabSelectionChange();
        }