private IdGamesTabViewCtrl CreateTabViewIdGames(ColumnConfig[] colConfig)
        {
            ColumnField[] columnTextFields = new ColumnField[]
            {
                new ColumnField("Title", "Title"),
                new ColumnField("Author", "Author"),
                new ColumnField("Description", "Description"),
                new ColumnField("Rating", "Rating"),
            };

            IdGamesDataSourceAdapter = new IdGamesDataAdapater(AppConfiguration.IdGamesUrl, AppConfiguration.ApiPage, AppConfiguration.MirrorUrl);
            IdGamesTabViewCtrl tabViewIdGames = new IdGamesTabViewCtrl(s_idGamesKey, s_idGamesKey, IdGamesDataSourceAdapter, DefaultGameFileSelectFields);

            SetupTabBase(tabViewIdGames, columnTextFields, colConfig, mnuIdGames, false);
            return(tabViewIdGames);
        }
Exemple #2
0
        private IdGamesTabViewCtrl CreateTabViewIdGames(ColumnConfig[] colConfig)
        {
            ColumnField[] columnTextFields = new ColumnField[]
            {
                new ColumnField("Title", "Title"),
                new ColumnField("Author", "Author"),
                new ColumnField("ReleaseDate", "Release Date"),
                new ColumnField("Description", "Description"),
                new ColumnField("Rating", "Rating"),
            };

            IdGamesDataSourceAdapter = new IdGamesDataAdapater(AppConfiguration.IdGamesUrl, AppConfiguration.ApiPage, AppConfiguration.MirrorUrl);
            var factory = new GameFileViewFactory(this, GameFileViewType.GridView);
            IdGamesTabViewCtrl tabViewIdGames = new IdGamesTabViewCtrl(TabKeys.IdGamesKey, StaticTagData.GetFavoriteName(TabKeys.IdGamesKey), IdGamesDataSourceAdapter, DefaultGameFileSelectFields, factory);

            SetupTabBase(tabViewIdGames, columnTextFields, colConfig, mnuIdGames, false);
            return(tabViewIdGames);
        }
Exemple #3
0
 private IEnumerable <IGameFile> GetMetaFiles(IdGamesDataAdapater adapter, string metaFileName)
 {
     return(adapter.GetGameFilesByName(metaFileName));
 }
Exemple #4
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);
                }
            }
        }
Exemple #5
0
        private void SetupTabs()
        {
            List <ITabView> tabViews = new List <ITabView>();

            ColumnConfig[] colConfig = GetColumnConfig();

            TagMapLookup = new TagMapLookup(DataSourceAdapter);

            ColumnField[] columnTextFields = DefaultColumnTextFields;

            OptionsTabViewCtrl tabViewRecent = new OptionsTabViewCtrl(s_recentKey, s_recentKey, DataSourceAdapter, DefaultGameFileSelectFields, TagMapLookup);

            tabViewRecent.SetColumnConfig(columnTextFields, colConfig);
            tabViewRecent.GameFileViewControl.SetContextMenuStrip(mnuLocal);
            tabViewRecent.GameFileViewControl.AllowDrop = true;
            tabViewRecent.Options            = new GameFileGetOptions();
            tabViewRecent.Options.Limit      = 10;
            tabViewRecent.Options.OrderBy    = OrderType.Desc;
            tabViewRecent.Options.OrderField = GameFileFieldType.Downloaded;

            SetGameFileViewEvents(tabViewRecent.GameFileViewControl, true);

            tabViews.Add(tabViewRecent);

            LocalTabViewCtrl tabViewLocal = new LocalTabViewCtrl(s_localKey, s_localKey, DataSourceAdapter, DefaultGameFileSelectFields, TagMapLookup);

            tabViewLocal.SetColumnConfig(columnTextFields, colConfig);
            tabViewLocal.GameFileViewControl.SetContextMenuStrip(mnuLocal);
            tabViewLocal.GameFileViewControl.AllowDrop = true;
            SetGameFileViewEvents(tabViewLocal.GameFileViewControl, true);

            tabViews.Add(tabViewLocal);

            columnTextFields = new ColumnField[]
            {
                new ColumnField("FileName", "File"),
                new ColumnField("Title", "Title"),
                new ColumnField("LastPlayed", "Last Played")
            };

            IWadTabViewCtrl tabViewIwads = new IWadTabViewCtrl(s_iwadKey, s_iwadKey, DataSourceAdapter, DefaultGameFileSelectFields, TagMapLookup);

            tabViewIwads.SetColumnConfig(columnTextFields, colConfig);
            tabViewIwads.GameFileViewControl.SetContextMenuStrip(mnuLocal);
            tabViewIwads.GameFileViewControl.AllowDrop = true;
            SetGameFileViewEvents(tabViewIwads.GameFileViewControl, true);

            tabViews.Add(tabViewIwads);

            columnTextFields = new ColumnField[]
            {
                new ColumnField("Title", "Title"),
                new ColumnField("Author", "Author"),
                new ColumnField("Description", "Description"),
                new ColumnField("Rating", "Rating"),
            };

            IdGamesDataSourceAdapter = new IdGamesDataAdapater(AppConfiguration.IdGamesUrl, AppConfiguration.ApiPage, AppConfiguration.MirrorUrl);
            IdGamesTabViewCtrl tabViewIdGames = new IdGamesTabViewCtrl(s_idGamesKey, s_idGamesKey, IdGamesDataSourceAdapter, DefaultGameFileSelectFields);

            tabViewIdGames.SetColumnConfig(columnTextFields, colConfig);
            tabViewIdGames.GameFileViewControl.SetContextMenuStrip(mnuIdGames);
            SetGameFileViewEvents(tabViewIdGames.GameFileViewControl, false);

            tabViews.Add(tabViewIdGames);

            tabViews.AddRange(CreateTagTabs(DefaultColumnTextFields, colConfig));

            m_tabHandler = new TabHandler(tabControl);
            m_tabHandler.SetTabs(tabViews);
        }