コード例 #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;

            CleanUpFiles();

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

            InitTagSelectControl();
            InitDownloadView();

            ctrlAssociationView.Initialize(DataSourceAdapter, AppConfiguration);
            ctrlAssociationView.FileDeleted        += ctrlAssociationView_FileDeleted;
            ctrlAssociationView.FileOrderChanged   += ctrlAssociationView_FileOrderChanged;
            ctrlAssociationView.RequestScreenshots += CtrlAssociationView_RequestScreenshots;
        }
コード例 #2
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();
        }