Esempio n. 1
0
        private async Task HandleSyncStatusGameFilesOption(SyncFileOption option, IEnumerable <string> files)
        {
            ProgressBarForm form = CreateProgressBar(string.Empty, ProgressBarStyle.Marquee);

            switch (option)
            {
            case SyncFileOption.Add:
                m_progressBarSync = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
                ProgressBarStart(m_progressBarSync);

                SyncLibraryHandler handler = await Task.Run(() => ExecuteSyncHandler(files.ToArray(), FileManagement.Managed));

                ProgressBarEnd(m_progressBarSync);
                SyncLocalDatabaseComplete(handler, true);
                break;

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

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

                ProgressBarEnd(form);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        private SyncLibraryHandler ExecuteSyncHandler(string[] files, FileManagement fileManagement, ITagData tag = null)
        {
            SyncLibraryHandler handler = null;

            try
            {
                handler = new SyncLibraryHandler(DataSourceAdapter, DirectoryDataSourceAdapter,
                                                 AppConfiguration.GameFileDirectory, AppConfiguration.TempDirectory, AppConfiguration.DateParseFormats, fileManagement);
                handler.SyncFileChange     += syncHandler_SyncFileChange;
                handler.GameFileDataNeeded += syncHandler_GameFileDataNeeded;

                handler.Execute(files);

                if (m_pendingZdlFiles != null)
                {
                    SyncPendingZdlFiles();
                    m_pendingZdlFiles = null;
                }

                if (tag != null)
                {
                    TagSyncFiles(handler, tag);
                }
            }
            catch (Exception ex)
            {
                Util.DisplayUnexpectedException(this, ex);
            }

            return(handler);
        }
Esempio n. 3
0
        void SyncLocalDatabaseComplete(SyncLibraryHandler handler, bool updateViews)
        {
            if (updateViews)
            {
                UpdateLocal();
                HandleTabSelectionChange();

                foreach (IGameFile updateGameFile in handler.UpdatedGameFiles)
                {
                    UpdateDataSourceViews(updateGameFile);
                }
            }

            if (handler != null &&
                (handler.InvalidFiles.Length > 0 || m_zdlInvalidFiles.Count > 0))
            {
                DisplayInvalidFilesError(handler.InvalidFiles.Union(m_zdlInvalidFiles));
            }
            else if (m_launchFile != null)
            {
                IGameFile launchFile = DataSourceAdapter.GetGameFile(Path.GetFileName(m_launchFile));
                m_launchFile = null;
                if (launchFile != null)
                {
                    HandlePlay(new IGameFile[] { launchFile });
                }
            }
        }
Esempio n. 4
0
 void ProgressBarUpdate(SyncLibraryHandler handler)
 {
     if (m_progressBarSync != null)
     {
         m_progressBarSync.Maximum     = handler.SyncFileCount;
         m_progressBarSync.Value       = handler.SyncFileCurrent;
         m_progressBarSync.DisplayText = string.Format("Reading {0}...", handler.CurrentSyncFileName);
     }
 }
Esempio n. 5
0
 void HandleGameFileDataNeeded(SyncLibraryHandler handler)
 {
     if (CurrentDownloadFile != null && CurrentDownloadFile.FileName == handler.CurrentGameFile.FileName)
     {
         handler.CurrentGameFile.Title       = CurrentDownloadFile.Title;
         handler.CurrentGameFile.Author      = CurrentDownloadFile.Author;
         handler.CurrentGameFile.ReleaseDate = CurrentDownloadFile.ReleaseDate;
     }
 }
Esempio n. 6
0
        private async Task SyncLocalDatabase(string[] fileNames)
        {
            m_progressBarSync = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
            ProgressBarStart(m_progressBarSync);

            SyncLibraryHandler handler = await Task.Run(() => ExecuteSyncHandler(fileNames));

            ProgressBarEnd(m_progressBarSync);
            SyncLocalDatabaseComplete(handler);
        }
Esempio n. 7
0
        private async Task SyncLocalDatabase(string[] fileNames, FileManagement fileManagement, bool updateViews, ITagData tag = null)
        {
            if (m_progressBarSync == null)
            {
                m_progressBarSync = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
                ProgressBarStart(m_progressBarSync);
            }

            SyncLibraryHandler handler = await Task.Run(() => ExecuteSyncHandler(fileNames, fileManagement, tag));

            ProgressBarEnd(m_progressBarSync);
            m_progressBarSync = null;
            SyncLocalDatabaseComplete(handler, updateViews);
        }
Esempio n. 8
0
        void syncHandler_GameFileDataNeeded(object sender, EventArgs e)
        {
            SyncLibraryHandler handler = sender as SyncLibraryHandler;

            if (handler != null)
            {
                if (InvokeRequired)
                {
                    Invoke(new Action <SyncLibraryHandler>(HandleGameFileDataNeeded), new object[] { handler });
                }
                else
                {
                    HandleGameFileDataNeeded(handler);
                }
            }
        }
Esempio n. 9
0
        void syncHandler_SyncFileChange(object sender, EventArgs e)
        {
            SyncLibraryHandler handler = sender as SyncLibraryHandler;

            if (handler != null)
            {
                if (InvokeRequired)
                {
                    Invoke(new Action <SyncLibraryHandler>(ProgressBarUpdate), new object[] { handler });
                }
                else
                {
                    ProgressBarUpdate(handler);
                }
            }
        }
Esempio n. 10
0
        void SyncLocalDatabaseComplete(SyncLibraryHandler handler)
        {
            SetIWadGameFiles();

            UpdateLocal();
            HandleTabSelectionChange();

            if (handler != null &&
                (handler.InvalidFiles.Length > 0 || m_zdlInvalidFiles.Count > 0))
            {
                DisplayInvalidFilesError(handler.InvalidFiles.Union(m_zdlInvalidFiles));
            }
            else if (m_launchFile != null)
            {
                IGameFile launchFile = DataSourceAdapter.GetGameFile(Path.GetFileName(m_launchFile));
                m_launchFile = null;
                if (launchFile != null)
                {
                    HandlePlay(new IGameFile[] { launchFile });
                }
            }
        }
Esempio n. 11
0
 private void TagSyncFiles(SyncLibraryHandler handler, ITagData tag)
 {
     DataCache.Instance.AddGameFileTag(handler.AddedGameFiles, tag, out _);
     DataCache.Instance.AddGameFileTag(handler.UpdatedGameFiles, tag, out _);
     DataCache.Instance.TagMapLookup.Refresh(new ITagData[] { tag });
 }