From 9b4ff872646858d5cd497496ead539da9db140d3 Mon Sep 17 00:00:00 2001 From: xantari Date: Wed, 24 Mar 2021 21:55:07 -0500 Subject: [PATCH] fixed related entry loading, null loading, switched to hashsets (should be faster) --- .../DatabaseBrowserForm.Designer.cs | 321 ++++++------ PinCab.Configurator/DatabaseBrowserForm.cs | 18 +- .../EditDatabaseEntryForm.Designer.cs | 482 ++++++++++++++++++ PinCab.Configurator/EditDatabaseEntryForm.cs | 100 ++++ .../EditDatabaseEntryForm.resx | 123 +++++ .../Pincab.Configurator.csproj | 9 + PinCab.Utils/Models/DatabaseBrowserEntry.cs | 8 +- PinCab.Utils/Utils/DatabaseManager.cs | 29 +- 8 files changed, 926 insertions(+), 164 deletions(-) create mode 100644 PinCab.Configurator/EditDatabaseEntryForm.Designer.cs create mode 100644 PinCab.Configurator/EditDatabaseEntryForm.cs create mode 100644 PinCab.Configurator/EditDatabaseEntryForm.resx diff --git a/PinCab.Configurator/DatabaseBrowserForm.Designer.cs b/PinCab.Configurator/DatabaseBrowserForm.Designer.cs index fa1bb92..5187337 100644 --- a/PinCab.Configurator/DatabaseBrowserForm.Designer.cs +++ b/PinCab.Configurator/DatabaseBrowserForm.Designer.cs @@ -54,6 +54,14 @@ private void InitializeComponent() this.lblRomSearch = new System.Windows.Forms.Label(); this.txtSearch = new System.Windows.Forms.TextBox(); this.dataGridViewEntryList = new System.Windows.Forms.DataGridView(); + this.titleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DatabaseTagsString = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Url = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IpdbId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Version = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.LastUpdated = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TypeString = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DatabaseTypeString = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.contextMenuStripGridActions = new System.Windows.Forms.ContextMenuStrip(this.components); this.IpdbInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.goToUrlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -62,6 +70,14 @@ private void InitializeComponent() this.splitContainerGridAndLog = new System.Windows.Forms.SplitContainer(); this.splitContainerTopAndBottomGrids = new System.Windows.Forms.SplitContainer(); this.dataGridViewChildEntries = new System.Windows.Forms.DataGridView(); + this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.contextMenuStripChildEntries = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItemChildIpdb = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemChildUrl = new System.Windows.Forms.ToolStripMenuItem(); @@ -71,22 +87,8 @@ private void InitializeComponent() this.toolStripStatusLabelSpacer = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar(); this.statusStripBottom = new System.Windows.Forms.StatusStrip(); - this.titleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.DatabaseTagsString = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Url = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.IpdbId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Version = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.LastUpdated = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.TypeString = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.DatabaseTypeString = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.panelFilterCriteria.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewEntryList)).BeginInit(); @@ -342,25 +344,95 @@ private void InitializeComponent() this.dataGridViewEntryList.RowContextMenuStripNeeded += new System.Windows.Forms.DataGridViewRowContextMenuStripNeededEventHandler(this.dataGridViewEntryList_RowContextMenuStripNeeded); this.dataGridViewEntryList.SelectionChanged += new System.EventHandler(this.dataGridViewEntryList_SelectionChanged); // + // titleDataGridViewTextBoxColumn + // + this.titleDataGridViewTextBoxColumn.DataPropertyName = "Title"; + this.titleDataGridViewTextBoxColumn.HeaderText = "Title"; + this.titleDataGridViewTextBoxColumn.Name = "titleDataGridViewTextBoxColumn"; + this.titleDataGridViewTextBoxColumn.ReadOnly = true; + this.titleDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.titleDataGridViewTextBoxColumn.Width = 52; + // + // DatabaseTagsString + // + this.DatabaseTagsString.DataPropertyName = "DatabaseTagsString"; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.DatabaseTagsString.DefaultCellStyle = dataGridViewCellStyle1; + this.DatabaseTagsString.HeaderText = "Tags"; + this.DatabaseTagsString.Name = "DatabaseTagsString"; + this.DatabaseTagsString.ReadOnly = true; + this.DatabaseTagsString.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.DatabaseTagsString.Width = 37; + // + // Url + // + this.Url.DataPropertyName = "Url"; + this.Url.HeaderText = "Url"; + this.Url.Name = "Url"; + this.Url.ReadOnly = true; + this.Url.Width = 45; + // + // IpdbId + // + this.IpdbId.DataPropertyName = "IpdbId"; + this.IpdbId.HeaderText = "Ipdb"; + this.IpdbId.Name = "IpdbId"; + this.IpdbId.ReadOnly = true; + this.IpdbId.Width = 53; + // + // Version + // + this.Version.DataPropertyName = "Version"; + this.Version.HeaderText = "Version"; + this.Version.Name = "Version"; + this.Version.ReadOnly = true; + this.Version.Width = 67; + // + // LastUpdated + // + this.LastUpdated.DataPropertyName = "LastUpdated"; + this.LastUpdated.HeaderText = "Updated"; + this.LastUpdated.Name = "LastUpdated"; + this.LastUpdated.ReadOnly = true; + this.LastUpdated.Width = 73; + // + // TypeString + // + this.TypeString.DataPropertyName = "TypeString"; + this.TypeString.HeaderText = "Type"; + this.TypeString.Name = "TypeString"; + this.TypeString.ReadOnly = true; + this.TypeString.Width = 56; + // + // DatabaseTypeString + // + this.DatabaseTypeString.DataPropertyName = "DatabaseName"; + this.DatabaseTypeString.HeaderText = "DB"; + this.DatabaseTypeString.Name = "DatabaseTypeString"; + this.DatabaseTypeString.ReadOnly = true; + this.DatabaseTypeString.Width = 47; + // // contextMenuStripGridActions // this.contextMenuStripGridActions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.IpdbInfoToolStripMenuItem, - this.goToUrlToolStripMenuItem}); + this.goToUrlToolStripMenuItem, + this.editToolStripMenuItem, + this.deleteToolStripMenuItem}); this.contextMenuStripGridActions.Name = "contextMenuStripGridActions"; - this.contextMenuStripGridActions.Size = new System.Drawing.Size(128, 48); + this.contextMenuStripGridActions.Size = new System.Drawing.Size(181, 114); // // IpdbInfoToolStripMenuItem // this.IpdbInfoToolStripMenuItem.Name = "IpdbInfoToolStripMenuItem"; - this.IpdbInfoToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.IpdbInfoToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.IpdbInfoToolStripMenuItem.Text = "IPDB Info"; this.IpdbInfoToolStripMenuItem.Click += new System.EventHandler(this.IpdbInfoToolStripMenuItem_Click); // // goToUrlToolStripMenuItem // this.goToUrlToolStripMenuItem.Name = "goToUrlToolStripMenuItem"; - this.goToUrlToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.goToUrlToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.goToUrlToolStripMenuItem.Text = "Go to URL"; this.goToUrlToolStripMenuItem.Click += new System.EventHandler(this.goToUrlToolStripMenuItem_Click); // @@ -442,137 +514,6 @@ private void InitializeComponent() this.dataGridViewChildEntries.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridViewChildEntries_DataBindingComplete); this.dataGridViewChildEntries.RowContextMenuStripNeeded += new System.Windows.Forms.DataGridViewRowContextMenuStripNeededEventHandler(this.dataGridViewChildEntries_RowContextMenuStripNeeded); // - // contextMenuStripChildEntries - // - this.contextMenuStripChildEntries.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemChildIpdb, - this.toolStripMenuItemChildUrl}); - this.contextMenuStripChildEntries.Name = "contextMenuStripGridActions"; - this.contextMenuStripChildEntries.Size = new System.Drawing.Size(128, 48); - // - // toolStripMenuItemChildIpdb - // - this.toolStripMenuItemChildIpdb.Name = "toolStripMenuItemChildIpdb"; - this.toolStripMenuItemChildIpdb.Size = new System.Drawing.Size(127, 22); - this.toolStripMenuItemChildIpdb.Text = "IPDB Info"; - this.toolStripMenuItemChildIpdb.Click += new System.EventHandler(this.toolStripMenuItemChildIpdb_Click); - // - // toolStripMenuItemChildUrl - // - this.toolStripMenuItemChildUrl.Name = "toolStripMenuItemChildUrl"; - this.toolStripMenuItemChildUrl.Size = new System.Drawing.Size(127, 22); - this.toolStripMenuItemChildUrl.Text = "Go to URL"; - this.toolStripMenuItemChildUrl.Click += new System.EventHandler(this.toolStripMenuItemChildUrl_Click); - // - // bindingSourceChildEntries - // - this.bindingSourceChildEntries.DataSource = typeof(PinCab.Utils.Models.DatabaseBrowserEntry); - // - // backgroundWorkerProgressBar - // - this.backgroundWorkerProgressBar.WorkerReportsProgress = true; - this.backgroundWorkerProgressBar.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorkerProgressBar_DoWork); - this.backgroundWorkerProgressBar.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorkerProgressBar_ProgressChanged); - this.backgroundWorkerProgressBar.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorkerProgressBar_RunWorkerCompleted); - // - // toolStripStatusLabel - // - this.toolStripStatusLabel.Name = "toolStripStatusLabel"; - this.toolStripStatusLabel.Size = new System.Drawing.Size(67, 17); - this.toolStripStatusLabel.Text = "Status Here"; - // - // toolStripStatusLabelSpacer - // - this.toolStripStatusLabelSpacer.Name = "toolStripStatusLabelSpacer"; - this.toolStripStatusLabelSpacer.Size = new System.Drawing.Size(865, 17); - this.toolStripStatusLabelSpacer.Spring = true; - // - // toolStripProgressBar - // - this.toolStripProgressBar.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.toolStripProgressBar.Name = "toolStripProgressBar"; - this.toolStripProgressBar.Size = new System.Drawing.Size(100, 16); - // - // statusStripBottom - // - this.statusStripBottom.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel, - this.toolStripStatusLabelSpacer, - this.toolStripProgressBar}); - this.statusStripBottom.Location = new System.Drawing.Point(0, 533); - this.statusStripBottom.Name = "statusStripBottom"; - this.statusStripBottom.Size = new System.Drawing.Size(1049, 22); - this.statusStripBottom.TabIndex = 6; - this.statusStripBottom.Text = "statusStrip1"; - // - // titleDataGridViewTextBoxColumn - // - this.titleDataGridViewTextBoxColumn.DataPropertyName = "Title"; - this.titleDataGridViewTextBoxColumn.HeaderText = "Title"; - this.titleDataGridViewTextBoxColumn.Name = "titleDataGridViewTextBoxColumn"; - this.titleDataGridViewTextBoxColumn.ReadOnly = true; - this.titleDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.titleDataGridViewTextBoxColumn.Width = 52; - // - // DatabaseTagsString - // - this.DatabaseTagsString.DataPropertyName = "DatabaseTagsString"; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.DatabaseTagsString.DefaultCellStyle = dataGridViewCellStyle1; - this.DatabaseTagsString.HeaderText = "Tags"; - this.DatabaseTagsString.Name = "DatabaseTagsString"; - this.DatabaseTagsString.ReadOnly = true; - this.DatabaseTagsString.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.DatabaseTagsString.Width = 37; - // - // Url - // - this.Url.DataPropertyName = "Url"; - this.Url.HeaderText = "Url"; - this.Url.Name = "Url"; - this.Url.ReadOnly = true; - this.Url.Width = 45; - // - // IpdbId - // - this.IpdbId.DataPropertyName = "IpdbId"; - this.IpdbId.HeaderText = "Ipdb"; - this.IpdbId.Name = "IpdbId"; - this.IpdbId.ReadOnly = true; - this.IpdbId.Width = 53; - // - // Version - // - this.Version.DataPropertyName = "Version"; - this.Version.HeaderText = "Version"; - this.Version.Name = "Version"; - this.Version.ReadOnly = true; - this.Version.Width = 67; - // - // LastUpdated - // - this.LastUpdated.DataPropertyName = "LastUpdated"; - this.LastUpdated.HeaderText = "Updated"; - this.LastUpdated.Name = "LastUpdated"; - this.LastUpdated.ReadOnly = true; - this.LastUpdated.Width = 73; - // - // TypeString - // - this.TypeString.DataPropertyName = "TypeString"; - this.TypeString.HeaderText = "Type"; - this.TypeString.Name = "TypeString"; - this.TypeString.ReadOnly = true; - this.TypeString.Width = 56; - // - // DatabaseTypeString - // - this.DatabaseTypeString.DataPropertyName = "DatabaseName"; - this.DatabaseTypeString.HeaderText = "DB"; - this.DatabaseTypeString.Name = "DatabaseTypeString"; - this.DatabaseTypeString.ReadOnly = true; - this.DatabaseTypeString.Width = 47; - // // dataGridViewTextBoxColumn1 // this.dataGridViewTextBoxColumn1.DataPropertyName = "Title"; @@ -641,6 +582,82 @@ private void InitializeComponent() this.dataGridViewTextBoxColumn8.ReadOnly = true; this.dataGridViewTextBoxColumn8.Width = 47; // + // contextMenuStripChildEntries + // + this.contextMenuStripChildEntries.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemChildIpdb, + this.toolStripMenuItemChildUrl}); + this.contextMenuStripChildEntries.Name = "contextMenuStripGridActions"; + this.contextMenuStripChildEntries.Size = new System.Drawing.Size(128, 48); + // + // toolStripMenuItemChildIpdb + // + this.toolStripMenuItemChildIpdb.Name = "toolStripMenuItemChildIpdb"; + this.toolStripMenuItemChildIpdb.Size = new System.Drawing.Size(127, 22); + this.toolStripMenuItemChildIpdb.Text = "IPDB Info"; + this.toolStripMenuItemChildIpdb.Click += new System.EventHandler(this.toolStripMenuItemChildIpdb_Click); + // + // toolStripMenuItemChildUrl + // + this.toolStripMenuItemChildUrl.Name = "toolStripMenuItemChildUrl"; + this.toolStripMenuItemChildUrl.Size = new System.Drawing.Size(127, 22); + this.toolStripMenuItemChildUrl.Text = "Go to URL"; + this.toolStripMenuItemChildUrl.Click += new System.EventHandler(this.toolStripMenuItemChildUrl_Click); + // + // bindingSourceChildEntries + // + this.bindingSourceChildEntries.DataSource = typeof(PinCab.Utils.Models.DatabaseBrowserEntry); + // + // backgroundWorkerProgressBar + // + this.backgroundWorkerProgressBar.WorkerReportsProgress = true; + this.backgroundWorkerProgressBar.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorkerProgressBar_DoWork); + this.backgroundWorkerProgressBar.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorkerProgressBar_ProgressChanged); + this.backgroundWorkerProgressBar.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorkerProgressBar_RunWorkerCompleted); + // + // toolStripStatusLabel + // + this.toolStripStatusLabel.Name = "toolStripStatusLabel"; + this.toolStripStatusLabel.Size = new System.Drawing.Size(67, 17); + this.toolStripStatusLabel.Text = "Status Here"; + // + // toolStripStatusLabelSpacer + // + this.toolStripStatusLabelSpacer.Name = "toolStripStatusLabelSpacer"; + this.toolStripStatusLabelSpacer.Size = new System.Drawing.Size(865, 17); + this.toolStripStatusLabelSpacer.Spring = true; + // + // toolStripProgressBar + // + this.toolStripProgressBar.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.toolStripProgressBar.Name = "toolStripProgressBar"; + this.toolStripProgressBar.Size = new System.Drawing.Size(100, 16); + // + // statusStripBottom + // + this.statusStripBottom.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel, + this.toolStripStatusLabelSpacer, + this.toolStripProgressBar}); + this.statusStripBottom.Location = new System.Drawing.Point(0, 533); + this.statusStripBottom.Name = "statusStripBottom"; + this.statusStripBottom.Size = new System.Drawing.Size(1049, 22); + this.statusStripBottom.TabIndex = 6; + this.statusStripBottom.Text = "statusStrip1"; + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.editToolStripMenuItem.Text = "Edit"; + this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + // // DatabaseBrowserForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -738,5 +755,7 @@ private void InitializeComponent() private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; } } \ No newline at end of file diff --git a/PinCab.Configurator/DatabaseBrowserForm.cs b/PinCab.Configurator/DatabaseBrowserForm.cs index d6c2607..281ecde 100644 --- a/PinCab.Configurator/DatabaseBrowserForm.cs +++ b/PinCab.Configurator/DatabaseBrowserForm.cs @@ -207,9 +207,12 @@ private void txtSearch_TextChanged(object sender, EventArgs e) private List GetEntriesByFilterCriteria() { + string searchTerm = txtSearch.Text.ToLower(); IEnumerable list; - list = _dbManager.Entries.Where(p => (p.Title.FuzzyMatch(txtSearch.Text) > .5) - || p.Title.ToLower().Contains(txtSearch.Text.ToLower())); //Search by text + list = _dbManager.Entries.Where(p => //(p.Title.FuzzyMatch(txtSearch.Text) > .1) + p.Title.ToLower().Contains(searchTerm) + || p.Description.ToLower().Contains(searchTerm) + ); //Search by text list = list.Where(p => p.LastUpdated <= dateTimePickerEnd.Value.EndOfDay() && p.LastUpdated >= dateTimePickerBegin.Value.BeginningOfDay()); @@ -671,5 +674,16 @@ private void chkFuzzyMatch_CheckedChanged(object sender, EventArgs e) if (!_loading) RebindGridUsingFilter(); } + + private void editToolStripMenuItem_Click(object sender, EventArgs e) + { + //Get the source database entry + + //Load the form + + //Upon Successful response update the entry + + //Save the pre-processed database again + } } } diff --git a/PinCab.Configurator/EditDatabaseEntryForm.Designer.cs b/PinCab.Configurator/EditDatabaseEntryForm.Designer.cs new file mode 100644 index 0000000..43e3311 --- /dev/null +++ b/PinCab.Configurator/EditDatabaseEntryForm.Designer.cs @@ -0,0 +1,482 @@ +namespace PinCab.Configurator +{ + partial class EditDatabaseEntryForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnSave = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.colorDialogDmdColor = new System.Windows.Forms.ColorDialog(); + this.txtIpdbNumber = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.txtTheme = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.numericYear = new System.Windows.Forms.NumericUpDown(); + this.numericPlayers = new System.Windows.Forms.NumericUpDown(); + this.label9 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtManufacturer = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.cmbCategory = new System.Windows.Forms.ComboBox(); + this.lblId = new System.Windows.Forms.Label(); + this.btnGameUrl = new System.Windows.Forms.Button(); + this.txtGameUrl = new System.Windows.Forms.TextBox(); + this.label17 = new System.Windows.Forms.Label(); + this.txtAdded = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); + this.txtVersion = new System.Windows.Forms.TextBox(); + this.txtAuthors = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.txtIpdb = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.txtAuthor = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txtFileName = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.txtTitle = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.txtUrl = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.lblManufacturer = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.numericYear)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericPlayers)).BeginInit(); + this.SuspendLayout(); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(12, 550); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 23); + this.btnSave.TabIndex = 8; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(118, 550); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 9; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // txtIpdbNumber + // + this.txtIpdbNumber.Enabled = false; + this.txtIpdbNumber.Location = new System.Drawing.Point(72, 439); + this.txtIpdbNumber.Name = "txtIpdbNumber"; + this.txtIpdbNumber.Size = new System.Drawing.Size(80, 20); + this.txtIpdbNumber.TabIndex = 116; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(21, 442); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(42, 13); + this.label14.TabIndex = 115; + this.label14.Text = "IPDB #"; + // + // txtTheme + // + this.txtTheme.Location = new System.Drawing.Point(72, 415); + this.txtTheme.Name = "txtTheme"; + this.txtTheme.Size = new System.Drawing.Size(366, 20); + this.txtTheme.TabIndex = 114; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(21, 418); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(40, 13); + this.label11.TabIndex = 113; + this.label11.Text = "Theme"; + // + // numericYear + // + this.numericYear.Location = new System.Drawing.Point(214, 389); + this.numericYear.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.numericYear.Name = "numericYear"; + this.numericYear.Size = new System.Drawing.Size(90, 20); + this.numericYear.TabIndex = 112; + // + // numericPlayers + // + this.numericPlayers.Location = new System.Drawing.Point(71, 389); + this.numericPlayers.Maximum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericPlayers.Name = "numericPlayers"; + this.numericPlayers.Size = new System.Drawing.Size(90, 20); + this.numericPlayers.TabIndex = 111; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(167, 391); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(29, 13); + this.label9.TabIndex = 110; + this.label9.Text = "Year"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 391); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(41, 13); + this.label2.TabIndex = 109; + this.label2.Text = "Players"; + // + // txtManufacturer + // + this.txtManufacturer.Location = new System.Drawing.Point(72, 364); + this.txtManufacturer.Name = "txtManufacturer"; + this.txtManufacturer.Size = new System.Drawing.Size(366, 20); + this.txtManufacturer.TabIndex = 108; + // + // button1 + // + this.button1.BackgroundImage = global::PinCab.Configurator.Properties.Resources.BrowserLink_75x; + this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button1.ForeColor = System.Drawing.SystemColors.Control; + this.button1.Location = new System.Drawing.Point(497, 69); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(27, 23); + this.button1.TabIndex = 107; + this.button1.UseVisualStyleBackColor = true; + // + // cmbCategory + // + this.cmbCategory.FormattingEnabled = true; + this.cmbCategory.Location = new System.Drawing.Point(71, 40); + this.cmbCategory.Name = "cmbCategory"; + this.cmbCategory.Size = new System.Drawing.Size(230, 21); + this.cmbCategory.TabIndex = 106; + // + // lblId + // + this.lblId.AutoSize = true; + this.lblId.Location = new System.Drawing.Point(68, 9); + this.lblId.Name = "lblId"; + this.lblId.Size = new System.Drawing.Size(88, 13); + this.lblId.TabIndex = 105; + this.lblId.Text = "(Auto Generated)"; + // + // btnGameUrl + // + this.btnGameUrl.BackgroundImage = global::PinCab.Configurator.Properties.Resources.BrowserLink_75x; + this.btnGameUrl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.btnGameUrl.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnGameUrl.ForeColor = System.Drawing.SystemColors.Control; + this.btnGameUrl.Location = new System.Drawing.Point(440, 507); + this.btnGameUrl.Name = "btnGameUrl"; + this.btnGameUrl.Size = new System.Drawing.Size(27, 23); + this.btnGameUrl.TabIndex = 104; + this.btnGameUrl.UseVisualStyleBackColor = true; + // + // txtGameUrl + // + this.txtGameUrl.Location = new System.Drawing.Point(68, 507); + this.txtGameUrl.Name = "txtGameUrl"; + this.txtGameUrl.Size = new System.Drawing.Size(366, 20); + this.txtGameUrl.TabIndex = 103; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(-1, 510); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(54, 13); + this.label17.TabIndex = 102; + this.label17.Text = "Game Url:"; + // + // txtAdded + // + this.txtAdded.Enabled = false; + this.txtAdded.Location = new System.Drawing.Point(71, 260); + this.txtAdded.Multiline = true; + this.txtAdded.Name = "txtAdded"; + this.txtAdded.Size = new System.Drawing.Size(421, 49); + this.txtAdded.TabIndex = 101; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(14, 263); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(48, 13); + this.label15.TabIndex = 100; + this.label15.Text = "Features"; + // + // txtVersion + // + this.txtVersion.Enabled = false; + this.txtVersion.Location = new System.Drawing.Point(71, 341); + this.txtVersion.Name = "txtVersion"; + this.txtVersion.Size = new System.Drawing.Size(80, 20); + this.txtVersion.TabIndex = 99; + // + // txtAuthors + // + this.txtAuthors.Location = new System.Drawing.Point(71, 315); + this.txtAuthors.Name = "txtAuthors"; + this.txtAuthors.Size = new System.Drawing.Size(420, 20); + this.txtAuthors.TabIndex = 98; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(20, 344); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(42, 13); + this.label13.TabIndex = 97; + this.label13.Text = "Version"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(19, 318); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(43, 13); + this.label12.TabIndex = 96; + this.label12.Text = "Authors"; + // + // txtIpdb + // + this.txtIpdb.Location = new System.Drawing.Point(71, 203); + this.txtIpdb.Multiline = true; + this.txtIpdb.Name = "txtIpdb"; + this.txtIpdb.Size = new System.Drawing.Size(420, 51); + this.txtIpdb.TabIndex = 95; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(2, 206); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(65, 13); + this.label10.TabIndex = 94; + this.label10.Text = "Change Log"; + // + // txtAuthor + // + this.txtAuthor.Location = new System.Drawing.Point(70, 151); + this.txtAuthor.Multiline = true; + this.txtAuthor.Name = "txtAuthor"; + this.txtAuthor.Size = new System.Drawing.Size(421, 46); + this.txtAuthor.TabIndex = 93; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(6, 154); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(60, 13); + this.label8.TabIndex = 92; + this.label8.Text = "Description"; + // + // txtFileName + // + this.txtFileName.Location = new System.Drawing.Point(71, 123); + this.txtFileName.Name = "txtFileName"; + this.txtFileName.Size = new System.Drawing.Size(420, 20); + this.txtFileName.TabIndex = 91; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(12, 126); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(54, 13); + this.label7.TabIndex = 90; + this.label7.Text = "File Name"; + // + // txtTitle + // + this.txtTitle.Location = new System.Drawing.Point(71, 97); + this.txtTitle.Name = "txtTitle"; + this.txtTitle.Size = new System.Drawing.Size(420, 20); + this.txtTitle.TabIndex = 89; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(33, 100); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(27, 13); + this.label6.TabIndex = 88; + this.label6.Text = "Title"; + // + // txtUrl + // + this.txtUrl.Location = new System.Drawing.Point(70, 71); + this.txtUrl.Name = "txtUrl"; + this.txtUrl.Size = new System.Drawing.Size(421, 20); + this.txtUrl.TabIndex = 87; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(38, 74); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(20, 13); + this.label5.TabIndex = 86; + this.label5.Text = "Url"; + // + // lblManufacturer + // + this.lblManufacturer.AutoSize = true; + this.lblManufacturer.Location = new System.Drawing.Point(-3, 367); + this.lblManufacturer.Name = "lblManufacturer"; + this.lblManufacturer.Size = new System.Drawing.Size(70, 13); + this.lblManufacturer.TabIndex = 85; + this.lblManufacturer.Text = "Manufacturer"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(13, 43); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(49, 13); + this.label4.TabIndex = 84; + this.label4.Text = "Category"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(43, 9); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(19, 13); + this.label3.TabIndex = 83; + this.label3.Text = "Id:"; + // + // EditDatabaseEntryForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(581, 583); + this.Controls.Add(this.txtIpdbNumber); + this.Controls.Add(this.label14); + this.Controls.Add(this.txtTheme); + this.Controls.Add(this.label11); + this.Controls.Add(this.numericYear); + this.Controls.Add(this.numericPlayers); + this.Controls.Add(this.label9); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtManufacturer); + this.Controls.Add(this.button1); + this.Controls.Add(this.cmbCategory); + this.Controls.Add(this.lblId); + this.Controls.Add(this.btnGameUrl); + this.Controls.Add(this.txtGameUrl); + this.Controls.Add(this.label17); + this.Controls.Add(this.txtAdded); + this.Controls.Add(this.label15); + this.Controls.Add(this.txtVersion); + this.Controls.Add(this.txtAuthors); + this.Controls.Add(this.label13); + this.Controls.Add(this.label12); + this.Controls.Add(this.txtIpdb); + this.Controls.Add(this.label10); + this.Controls.Add(this.txtAuthor); + this.Controls.Add(this.label8); + this.Controls.Add(this.txtFileName); + this.Controls.Add(this.label7); + this.Controls.Add(this.txtTitle); + this.Controls.Add(this.label6); + this.Controls.Add(this.txtUrl); + this.Controls.Add(this.label5); + this.Controls.Add(this.lblManufacturer); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSave); + this.MinimumSize = new System.Drawing.Size(550, 622); + this.Name = "EditDatabaseEntryForm"; + this.Text = "Edit Game"; + ((System.ComponentModel.ISupportInitialize)(this.numericYear)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericPlayers)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.ColorDialog colorDialogDmdColor; + private System.Windows.Forms.TextBox txtIpdbNumber; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.TextBox txtTheme; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.NumericUpDown numericYear; + private System.Windows.Forms.NumericUpDown numericPlayers; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtManufacturer; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ComboBox cmbCategory; + private System.Windows.Forms.Label lblId; + private System.Windows.Forms.Button btnGameUrl; + private System.Windows.Forms.TextBox txtGameUrl; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.TextBox txtAdded; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox txtVersion; + private System.Windows.Forms.TextBox txtAuthors; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox txtIpdb; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox txtAuthor; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txtFileName; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtTitle; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtUrl; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label lblManufacturer; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + } +} \ No newline at end of file diff --git a/PinCab.Configurator/EditDatabaseEntryForm.cs b/PinCab.Configurator/EditDatabaseEntryForm.cs new file mode 100644 index 0000000..11462b6 --- /dev/null +++ b/PinCab.Configurator/EditDatabaseEntryForm.cs @@ -0,0 +1,100 @@ +using PinCab.Utils; +using PinCab.Utils.Extensions; +using PinCab.Utils.Models; +using PinCab.Utils.Utils; +using PinCab.Utils.ViewModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PinCab.Configurator +{ + public partial class EditDatabaseEntryForm : Form + { + private FrontEndGameViewModel _setting { get; set; } + //private string originalFileName { get; set; } + private FrontEndManager _manager { get; set; } + private string _databaseFile { get; set; } + private IpdbBrowserForm _ipdbForm = null; + private bool isNewEntry = false; + public EditDatabaseEntryForm(FrontEndGameViewModel setting, string databaseFile, FrontEndManager manager, IpdbBrowserForm ipdbForm) + { + InitializeComponent(); + } + + private void LoadForm() + { + txtManufacturer.Text = _setting.Manufacturer; + txtTheme.Text = _setting.Theme; + txtAuthor.Text = _setting.Author; + txtVersion.Text = _setting.Version; + txtIpdb.Text = _setting.IPDBNumber; + txtAdded.Text = _setting.DateAdded.ToString(); + txtGameUrl.Text = _setting.TableFileUrl; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void btnSave_Click(object sender, EventArgs e) + { + //var result = GetSettingFromControls(); + //if (string.IsNullOrEmpty(result.Description)) + //{ + // MessageBox.Show("Description is a required field"); + // return; + //} + //if (string.IsNullOrEmpty(result.FileName)) + //{ + // MessageBox.Show("File Name is a required field"); + // return; + //} + + //_manager.SaveGame(result, null); + //DialogResult = DialogResult.OK; + //Close(); + } + + private void btnIpdbUrl_Click(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(txtIpdb.Text)) + System.Diagnostics.Process.Start("https://www.ipdb.org/machine.cgi?id=" + txtIpdb.Text); + } + + private void btnFillFromIpdb_Click(object sender, EventArgs e) + { + //_ipdbForm.SearchText(txtTableName.Text); + //if (isNewEntry) + // _ipdbForm.chkOverrideDisplayName.Checked = true; + //var result = _ipdbForm.ShowDialog(this); + //if (result == DialogResult.OK) + //{ + // //Fill the data + // var ipdbEntry = _ipdbForm.GetActiveRowEntry(); + // if (_ipdbForm.chkOverrideDisplayName.Checked) + // txtDisplayName.Text = ipdbEntry.Title; + // txtManufacturer.Text = ipdbEntry.ManufacturerShortName; + // txtYear.Text = ipdbEntry.DateOfManufacture?.Year.ToString(); + // txtTheme.Text = ipdbEntry.Theme; + // txtIpdb.Text = ipdbEntry.IpdbId.ToString(); + // txtType.Text = ipdbEntry.TypeShortName; + // txtPlayers.Text = ipdbEntry.Players.ToString(); + //} + } + + private void btnGameUrl_Click(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(txtGameUrl.Text)) + System.Diagnostics.Process.Start(txtGameUrl.Text); + } + } +} diff --git a/PinCab.Configurator/EditDatabaseEntryForm.resx b/PinCab.Configurator/EditDatabaseEntryForm.resx new file mode 100644 index 0000000..264a001 --- /dev/null +++ b/PinCab.Configurator/EditDatabaseEntryForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/PinCab.Configurator/Pincab.Configurator.csproj b/PinCab.Configurator/Pincab.Configurator.csproj index 1cb7bf2..26d8bcc 100644 --- a/PinCab.Configurator/Pincab.Configurator.csproj +++ b/PinCab.Configurator/Pincab.Configurator.csproj @@ -154,6 +154,12 @@ AboutBoxForm.cs + + Form + + + EditDatabaseEntryForm.cs + Form @@ -247,6 +253,9 @@ AboutBoxForm.cs + + EditDatabaseEntryForm.cs + RenameGameForm.cs diff --git a/PinCab.Utils/Models/DatabaseBrowserEntry.cs b/PinCab.Utils/Models/DatabaseBrowserEntry.cs index 26202b7..7988a6c 100644 --- a/PinCab.Utils/Models/DatabaseBrowserEntry.cs +++ b/PinCab.Utils/Models/DatabaseBrowserEntry.cs @@ -13,15 +13,15 @@ public class DatabaseBrowserEntry { public DatabaseBrowserEntry() { - RelatedEntries = new List(); - Tags = new List(); + RelatedEntries = new HashSet(); + Tags = new HashSet(); } public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string ChangeLog { get; set; } public string Authors { get; set; } - public List Tags { get; set; } + public HashSet Tags { get; set; } public string Url { get; set; } public int? IpdbId { get; set; } public string Version { get; set; } @@ -53,7 +53,7 @@ public string DatabaseTagsString } } - public List RelatedEntries { get; set; } + public HashSet RelatedEntries { get; set; } public Uri GetUri() { diff --git a/PinCab.Utils/Utils/DatabaseManager.cs b/PinCab.Utils/Utils/DatabaseManager.cs index ef04dfe..8461d54 100644 --- a/PinCab.Utils/Utils/DatabaseManager.cs +++ b/PinCab.Utils/Utils/DatabaseManager.cs @@ -272,9 +272,9 @@ public List GetEntrysByDatabase(ContentDatabase database, return null; } - private List GetDatabaseBrowserEntries(ContentDatabase database) + private HashSet GetDatabaseBrowserEntries(ContentDatabase database) { - List entries = new List(); + HashSet entries = new HashSet(); foreach (var databaseEntry in Databases[database.Name].Entries) { var entry = GetDatabaseBrowserEntry(database, databaseEntry); @@ -282,6 +282,20 @@ private List GetDatabaseBrowserEntries(ContentDatabase dat entries.Add(entry); else Log.Information("{tool}: Skipped adding {entry} because it didn't pass the data check.", ToolName, entry.Title); + + //Add the related entries + foreach(var relatedEntry in databaseEntry.RelatedEntries) + { + var relatedContentEntry = Databases[database.Name].Entries.FirstOrDefault(c => c.Id == relatedEntry); + var newEntry = GetDatabaseBrowserEntry(database, relatedContentEntry); + if (IsValidBrowserEntry(newEntry)) + { + entry.RelatedEntries.Add(newEntry); + entry.Tags.UnionWith(newEntry.Tags); + } + else + Log.Information("{tool}: Skipped related entry adding {entry} because it didn't pass the data check.", ToolName, relatedContentEntry.Title); + } } //Rescan the related entries and fill in missing tags that we were able to find for the URL in a different @@ -311,7 +325,8 @@ public HashSet GetAllTags(List entries, bool repor { var entryTags = GetTags(entry); foreach (var itm in entryTags) - tags.Add(itm); + if (itm != null) + tags.Add(itm); } if (reportProgress) _reportProgress?.Invoke(100); @@ -352,7 +367,7 @@ private DatabaseBrowserEntry GetDatabaseBrowserEntry(ContentDatabase database, D Type = file.MajorCategory, Url = file.Url, Version = file.Version, - Tags = file.Tags, + Tags = file.Tags.ToHashSet(), DatabaseName = database.Name, LastUpdated = file.LastModifiedDateUtc.HasValue ? file.LastModifiedDateUtc.Value : new DateTime(1900, 1, 1), }; @@ -372,11 +387,11 @@ private DatabaseBrowserEntry GetDatabaseBrowserEntry(ContentDatabase database, D entry.Description += "\r\n\r\nFeatures:\r\n" + file.Features; var tableInfoTags = file.ConvertTableInfoToTags(); - entry.Tags.AddRange(tableInfoTags); + entry.Tags.UnionWith(tableInfoTags); List TagsByIpdbNumber = GetIpdbTags(entry); - entry.Tags.AddRange(TagsByIpdbNumber); - entry.Tags = entry.Tags.NormalizeTagList(); + entry.Tags.UnionWith(TagsByIpdbNumber); + //entry.Tags = entry.Tags.NormalizeTagList(); return entry; }