From: <che...@us...> - 2007-06-10 20:58:26
|
Revision: 510 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=510&view=rev Author: chef_koch Date: 2007-06-10 13:58:23 -0700 (Sun, 10 Jun 2007) Log Message: ----------- merged first layout redesign - revert this pls, if you don't like it should be the last merge from old plugin, so all future code changes i'll made will be exclusive for new-MyPrograms Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.resx Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs 2007-06-10 20:11:31 UTC (rev 509) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs 2007-06-10 20:58:23 UTC (rev 510) @@ -28,13 +28,14 @@ using System.Diagnostics; using System.Drawing; using System.Windows.Forms; +using System.Threading; -using GUIPrograms; -using GUIPrograms.Database; +using MediaPortal.GUI.Library; + using GUIPrograms.ApplicationItems; using GUIPrograms.FileItems; +using GUIPrograms.Imports; - namespace GUIPrograms.Design { /// <summary> @@ -42,52 +43,60 @@ /// </summary> public class FileInfoScraperForm : Form { + #region InitControls + private ApplicationItem m_CurApp; - private Panel leftPanel; - private Panel rightPanel; - private Splitter splitterVert; - private ListView FileList; + private MediaPortal.UserInterface.Controls.MPListView listViewFileList; private ColumnHeader FileTitle; - private ColumnHeader columnHeader1; private ColumnHeader status; - private ColumnHeader columnHeader2; - private ListView MatchList; - private Label lblFiles; - private Label lblMatches; - private Button btnStartSearch; - private Button btnSaveSearch; - private Button btnCancel; - private LinkLabel allGameLink; - private Button checkAllButton; + private MediaPortal.UserInterface.Controls.MPButton buttonStartSearch; + private MediaPortal.UserInterface.Controls.MPButton buttonSaveSearch; + private MediaPortal.UserInterface.Controls.MPButton buttonClose; + private LinkLabel linkLabelAllGame; private ToolTip toolTip1; - private Button uncheckAllButton; - private Button buttonSelectBestMatch; - private Label filterLabel; - private ComboBox filterComboBox; - private Button ResetFilterButton; + private MediaPortal.UserInterface.Controls.MPComboBox filterComboBox; + private MediaPortal.UserInterface.Controls.MPButton ResetFilterButton; private NumericUpDown MinRelevanceNum; - private Label label1; - private Button LaunchURLButton; + private MediaPortal.UserInterface.Controls.MPLabel label1; private Panel bottomPanel; private ContextMenu menuFileList; private MenuItem mnuCheckWithoutImages; private MenuItem mnuCheckWithoutOverview; - private ProgressBar progressBar; - private Panel progressPanel; - private Label progressStatusLabel; - private Button cancelButton; private IContainer components; - - int mStartTime = 0; // timer stuff private ContextMenu menuSaveDetails; private MenuItem menuItem4; private MenuItem menuDataAndImages; private MenuItem menuData; private MenuItem menuImages; + private MediaPortal.UserInterface.Controls.MPGroupBox groupBoxMatchList; + private MediaPortal.UserInterface.Controls.MPListView listViewMatchList; + private ColumnHeader columnHeader1; + private ColumnHeader columnHeader2; + private MediaPortal.UserInterface.Controls.MPGroupBox groupBoxFileList; + private MediaPortal.UserInterface.Controls.MPCheckBox checkboxFileList; private MediaPortal.UserInterface.Controls.MPLabel label2; + private MediaPortal.UserInterface.Controls.MPLabel labelLaunchUrlInfo; + + #endregion + + #region Variables / Init + + int mStartTime = 0; + private SplitContainer splitContainer1; + private MediaPortal.UserInterface.Controls.MPGroupBox groupBoxFilter; + private StatusStrip statusStrip; + private ToolStripStatusLabel toolStripStatusLabel; + private ToolStripProgressBar toolStripProgressBar; + private MediaPortal.UserInterface.Controls.MPLabel labelPlatform; + private ToolStripDropDownButton toolStripDropDownButton1; + private ToolStripMenuItem cancelSearchToolStripMenuItem; // timer stuff + + bool isSearching = false; bool stopSearching = false; + ScraperSaveType saveType = ScraperSaveType.DataAndImages; + public ApplicationItem CurApp { get @@ -136,549 +145,207 @@ base.Dispose(disposing); } - #region Windows Form Designer generated code - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() + public void Setup() { - this.components = new System.ComponentModel.Container(); - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FileInfoScraperForm)); - this.bottomPanel = new System.Windows.Forms.Panel(); - this.label2 = new MediaPortal.UserInterface.Controls.MPLabel(); - this.progressPanel = new System.Windows.Forms.Panel(); - this.cancelButton = new MediaPortal.UserInterface.Controls.MPButton(); - this.progressStatusLabel = new MediaPortal.UserInterface.Controls.MPLabel(); - this.progressBar = new System.Windows.Forms.ProgressBar(); - this.label1 = new MediaPortal.UserInterface.Controls.MPLabel(); - this.MinRelevanceNum = new System.Windows.Forms.NumericUpDown(); - this.ResetFilterButton = new MediaPortal.UserInterface.Controls.MPButton(); - this.filterComboBox = new MediaPortal.UserInterface.Controls.MPComboBox(); - this.filterLabel = new MediaPortal.UserInterface.Controls.MPLabel(); - this.buttonSelectBestMatch = new MediaPortal.UserInterface.Controls.MPButton(); - this.allGameLink = new System.Windows.Forms.LinkLabel(); - this.btnCancel = new MediaPortal.UserInterface.Controls.MPButton(); - this.btnSaveSearch = new MediaPortal.UserInterface.Controls.MPButton(); - this.btnStartSearch = new MediaPortal.UserInterface.Controls.MPButton(); - this.leftPanel = new System.Windows.Forms.Panel(); - this.uncheckAllButton = new MediaPortal.UserInterface.Controls.MPButton(); - this.checkAllButton = new MediaPortal.UserInterface.Controls.MPButton(); - this.lblFiles = new MediaPortal.UserInterface.Controls.MPLabel(); - this.FileList = new System.Windows.Forms.ListView(); - this.FileTitle = new System.Windows.Forms.ColumnHeader(); - this.status = new System.Windows.Forms.ColumnHeader(); - this.menuFileList = new System.Windows.Forms.ContextMenu(); - this.mnuCheckWithoutImages = new System.Windows.Forms.MenuItem(); - this.mnuCheckWithoutOverview = new System.Windows.Forms.MenuItem(); - this.splitterVert = new System.Windows.Forms.Splitter(); - this.rightPanel = new System.Windows.Forms.Panel(); - this.LaunchURLButton = new MediaPortal.UserInterface.Controls.MPButton(); - this.lblMatches = new MediaPortal.UserInterface.Controls.MPLabel(); - this.MatchList = new System.Windows.Forms.ListView(); - this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); - this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.menuSaveDetails = new System.Windows.Forms.ContextMenu(); - this.menuDataAndImages = new System.Windows.Forms.MenuItem(); - this.menuItem4 = new System.Windows.Forms.MenuItem(); - this.menuData = new System.Windows.Forms.MenuItem(); - this.menuImages = new System.Windows.Forms.MenuItem(); - this.bottomPanel.SuspendLayout(); - this.progressPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.MinRelevanceNum)).BeginInit(); - this.leftPanel.SuspendLayout(); - this.rightPanel.SuspendLayout(); - this.SuspendLayout(); - // - // bottomPanel - // - this.bottomPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.bottomPanel.Controls.Add(this.label2); - this.bottomPanel.Controls.Add(this.progressPanel); - this.bottomPanel.Controls.Add(this.label1); - this.bottomPanel.Controls.Add(this.MinRelevanceNum); - this.bottomPanel.Controls.Add(this.ResetFilterButton); - this.bottomPanel.Controls.Add(this.filterComboBox); - this.bottomPanel.Controls.Add(this.filterLabel); - this.bottomPanel.Controls.Add(this.buttonSelectBestMatch); - this.bottomPanel.Controls.Add(this.allGameLink); - this.bottomPanel.Controls.Add(this.btnCancel); - this.bottomPanel.Controls.Add(this.btnSaveSearch); - this.bottomPanel.Controls.Add(this.btnStartSearch); - this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom; - this.bottomPanel.Location = new System.Drawing.Point(0, 422); - this.bottomPanel.Name = "bottomPanel"; - this.bottomPanel.Size = new System.Drawing.Size(752, 112); - this.bottomPanel.TabIndex = 0; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(520, 8); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(224, 40); - this.label2.TabIndex = 28; - this.label2.Text = "Warning: Don\'t overuse the allgame scraper! Do lookups with small sets of games (" + - "max. 20 games)."; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // progressPanel - // - this.progressPanel.Controls.Add(this.cancelButton); - this.progressPanel.Controls.Add(this.progressStatusLabel); - this.progressPanel.Controls.Add(this.progressBar); - this.progressPanel.Enabled = false; - this.progressPanel.Location = new System.Drawing.Point(8, 69); - this.progressPanel.Name = "progressPanel"; - this.progressPanel.Size = new System.Drawing.Size(480, 40); - this.progressPanel.TabIndex = 27; - // - // cancelButton - // - this.cancelButton.Location = new System.Drawing.Point(392, 16); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(88, 23); - this.cancelButton.TabIndex = 29; - this.cancelButton.Text = "Cancel Search"; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // progressStatusLabel - // - this.progressStatusLabel.Location = new System.Drawing.Point(0, 20); - this.progressStatusLabel.Name = "progressStatusLabel"; - this.progressStatusLabel.Size = new System.Drawing.Size(392, 16); - this.progressStatusLabel.TabIndex = 28; - this.progressStatusLabel.Text = "Progress status"; - // - // progressBar - // - this.progressBar.Location = new System.Drawing.Point(0, 0); - this.progressBar.Name = "progressBar"; - this.progressBar.Size = new System.Drawing.Size(480, 16); - this.progressBar.TabIndex = 27; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(344, 6); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(88, 14); - this.label1.TabIndex = 25; - this.label1.Text = "Min. Relevance"; - // - // MinRelevanceNum - // - this.MinRelevanceNum.Increment = new System.Decimal(new int[] { - 10, - 0, - 0, - 0}); - this.MinRelevanceNum.Location = new System.Drawing.Point(432, 3); - this.MinRelevanceNum.Name = "MinRelevanceNum"; - this.MinRelevanceNum.Size = new System.Drawing.Size(56, 20); - this.MinRelevanceNum.TabIndex = 24; - this.toolTip1.SetToolTip(this.MinRelevanceNum, "This is the minimal RELEVANCE value to autoselect a match"); - this.MinRelevanceNum.Value = new System.Decimal(new int[] { - 70, - 0, - 0, - 0}); - this.MinRelevanceNum.ValueChanged += new System.EventHandler(this.MinRelevanceNum_ValueChanged); - // - // ResetFilterButton - // - this.ResetFilterButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.ResetFilterButton.Location = new System.Drawing.Point(282, 3); - this.ResetFilterButton.Name = "ResetFilterButton"; - this.ResetFilterButton.Size = new System.Drawing.Size(40, 21); - this.ResetFilterButton.TabIndex = 23; - this.ResetFilterButton.Text = "Clear"; - this.toolTip1.SetToolTip(this.ResetFilterButton, "Reset Filter"); - this.ResetFilterButton.Click += new System.EventHandler(this.ResetFilterButton_Click); - // - // filterComboBox - // - this.filterComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.filterComboBox.Items.AddRange(new object[] { - "Arcade", - "Atari 5200", - "Atari 7800", - "Atari Lynx", - "Atari ST", - "Atari Video Computer System", - "Commodore 64/128", - "Commodore Amiga", - "Game Boy", - "Game Boy Advance", - "Game Boy Color", - "Neo Geo", - "Nintendo 64", - "Nintendo Entertainment System", - "PlayStation", - "Sega Dreamcast", - "Sega Game Gear", - "Sega Genesis", - "Sega Master System", - "Super NES", - "TurboGrafx-16"}); - this.filterComboBox.Location = new System.Drawing.Point(72, 3); - this.filterComboBox.Name = "filterComboBox"; - this.filterComboBox.Size = new System.Drawing.Size(208, 21); - this.filterComboBox.TabIndex = 22; - this.toolTip1.SetToolTip(this.filterComboBox, "Enter platform to filter results"); - this.filterComboBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.filterComboBox_KeyUp); - this.filterComboBox.SelectedIndexChanged += new System.EventHandler(this.filterComboBox_SelectedIndexChanged); - // - // filterLabel - // - this.filterLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.filterLabel.Location = new System.Drawing.Point(8, 5); - this.filterLabel.Name = "filterLabel"; - this.filterLabel.Size = new System.Drawing.Size(80, 16); - this.filterLabel.TabIndex = 21; - this.filterLabel.Text = "Platform:"; - // - // buttonSelectBestMatch - // - this.buttonSelectBestMatch.Enabled = false; - this.buttonSelectBestMatch.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.buttonSelectBestMatch.Location = new System.Drawing.Point(168, 32); - this.buttonSelectBestMatch.Name = "buttonSelectBestMatch"; - this.buttonSelectBestMatch.Size = new System.Drawing.Size(160, 32); - this.buttonSelectBestMatch.TabIndex = 20; - this.buttonSelectBestMatch.Text = "2) Select Best Match"; - this.toolTip1.SetToolTip(this.buttonSelectBestMatch, "Select the best match for all checked files ("); - this.buttonSelectBestMatch.Click += new System.EventHandler(this.buttonSelectBestMatch_Click); - // - // allGameLink - // - this.allGameLink.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.allGameLink.Location = new System.Drawing.Point(616, 56); - this.allGameLink.Name = "allGameLink"; - this.allGameLink.Size = new System.Drawing.Size(128, 16); - this.allGameLink.TabIndex = 3; - this.allGameLink.TabStop = true; - this.allGameLink.Text = "http://www.allgame.com"; - this.allGameLink.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.allGameLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.allGameLink_LinkClicked); - // - // btnCancel - // - this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.Location = new System.Drawing.Point(668, 76); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.TabIndex = 2; - this.btnCancel.Text = "Close"; - this.btnCancel.Click += new System.EventHandler(this.button3_Click); - // - // btnSaveSearch - // - this.btnSaveSearch.Enabled = false; - this.btnSaveSearch.Location = new System.Drawing.Point(328, 32); - this.btnSaveSearch.Name = "btnSaveSearch"; - this.btnSaveSearch.Size = new System.Drawing.Size(160, 32); - this.btnSaveSearch.TabIndex = 1; - this.btnSaveSearch.Text = "3) Download && Save Details"; - this.toolTip1.SetToolTip(this.btnSaveSearch, "Download selected matches and save results to MediaPortal!"); - this.btnSaveSearch.Click += new System.EventHandler(this.btnSaveSearch_Click); - // - // btnStartSearch - // - this.btnStartSearch.Enabled = false; - this.btnStartSearch.Location = new System.Drawing.Point(8, 32); - this.btnStartSearch.Name = "btnStartSearch"; - this.btnStartSearch.Size = new System.Drawing.Size(160, 32); - this.btnStartSearch.TabIndex = 0; - this.btnStartSearch.Text = "1) Start Search"; - this.toolTip1.SetToolTip(this.btnStartSearch, "Search Details for all the checked files"); - this.btnStartSearch.Click += new System.EventHandler(this.btnStartSearch_Click); - // - // leftPanel - // - this.leftPanel.Controls.Add(this.uncheckAllButton); - this.leftPanel.Controls.Add(this.checkAllButton); - this.leftPanel.Controls.Add(this.lblFiles); - this.leftPanel.Controls.Add(this.FileList); - this.leftPanel.Dock = System.Windows.Forms.DockStyle.Left; - this.leftPanel.Location = new System.Drawing.Point(0, 0); - this.leftPanel.Name = "leftPanel"; - this.leftPanel.Size = new System.Drawing.Size(360, 422); - this.leftPanel.TabIndex = 5; - // - // uncheckAllButton - // - this.uncheckAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.uncheckAllButton.Image = ((System.Drawing.Image)(resources.GetObject("uncheckAllButton.Image"))); - this.uncheckAllButton.Location = new System.Drawing.Point(320, 8); - this.uncheckAllButton.Name = "uncheckAllButton"; - this.uncheckAllButton.Size = new System.Drawing.Size(32, 32); - this.uncheckAllButton.TabIndex = 16; - this.toolTip1.SetToolTip(this.uncheckAllButton, "Uncheck all"); - this.uncheckAllButton.Click += new System.EventHandler(this.uncheckAllButton_Click); - // - // checkAllButton - // - this.checkAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.checkAllButton.Image = ((System.Drawing.Image)(resources.GetObject("checkAllButton.Image"))); - this.checkAllButton.Location = new System.Drawing.Point(288, 8); - this.checkAllButton.Name = "checkAllButton"; - this.checkAllButton.Size = new System.Drawing.Size(32, 32); - this.checkAllButton.TabIndex = 15; - this.toolTip1.SetToolTip(this.checkAllButton, "Check all"); - this.checkAllButton.Click += new System.EventHandler(this.checkAllButton_Click); - // - // lblFiles - // - this.lblFiles.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.lblFiles.Location = new System.Drawing.Point(8, 16); - this.lblFiles.Name = "lblFiles"; - this.lblFiles.Size = new System.Drawing.Size(200, 16); - this.lblFiles.TabIndex = 14; - this.lblFiles.Text = "Files"; - // - // FileList - // - this.FileList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.FileList.CheckBoxes = true; - this.FileList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.FileTitle, - this.status}); - this.FileList.ContextMenu = this.menuFileList; - this.FileList.FullRowSelect = true; - this.FileList.HideSelection = false; - this.FileList.LabelEdit = true; - this.FileList.Location = new System.Drawing.Point(8, 40); - this.FileList.Name = "FileList"; - this.FileList.Size = new System.Drawing.Size(344, 368); - this.FileList.TabIndex = 13; - this.FileList.View = System.Windows.Forms.View.Details; - this.FileList.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FileList_MouseUp); - this.FileList.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.FileList_AfterLabelEdit); - this.FileList.SelectedIndexChanged += new System.EventHandler(this.FileList_SelectedIndexChanged); - // - // FileTitle - // - this.FileTitle.Text = "Title"; - this.FileTitle.Width = 218; - // - // status - // - this.status.Text = "Status"; - this.status.Width = 102; - // - // menuFileList - // - this.menuFileList.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.mnuCheckWithoutImages, - this.mnuCheckWithoutOverview}); - // - // mnuCheckWithoutImages - // - this.mnuCheckWithoutImages.Index = 0; - this.mnuCheckWithoutImages.Text = "Check all files without images"; - this.mnuCheckWithoutImages.Click += new System.EventHandler(this.mnuCheckWithoutImages_Click); - // - // mnuCheckWithoutOverview - // - this.mnuCheckWithoutOverview.Index = 1; - this.mnuCheckWithoutOverview.Text = "Check all files without an overview"; - this.mnuCheckWithoutOverview.Click += new System.EventHandler(this.mnuCheckWithoutOverview_Click); - // - // splitterVert - // - this.splitterVert.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.splitterVert.Location = new System.Drawing.Point(360, 0); - this.splitterVert.Name = "splitterVert"; - this.splitterVert.Size = new System.Drawing.Size(5, 422); - this.splitterVert.TabIndex = 6; - this.splitterVert.TabStop = false; - // - // rightPanel - // - this.rightPanel.Controls.Add(this.LaunchURLButton); - this.rightPanel.Controls.Add(this.lblMatches); - this.rightPanel.Controls.Add(this.MatchList); - this.rightPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.rightPanel.Location = new System.Drawing.Point(365, 0); - this.rightPanel.Name = "rightPanel"; - this.rightPanel.Size = new System.Drawing.Size(387, 422); - this.rightPanel.TabIndex = 7; - // - // LaunchURLButton - // - this.LaunchURLButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.LaunchURLButton.Enabled = false; - this.LaunchURLButton.Location = new System.Drawing.Point(272, 12); - this.LaunchURLButton.Name = "LaunchURLButton"; - this.LaunchURLButton.Size = new System.Drawing.Size(104, 24); - this.LaunchURLButton.TabIndex = 16; - this.LaunchURLButton.Text = "Launch URL"; - this.toolTip1.SetToolTip(this.LaunchURLButton, "Show allgame-page in your browser"); - this.LaunchURLButton.Click += new System.EventHandler(this.LaunchURLButton_Click); - // - // lblMatches - // - this.lblMatches.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.lblMatches.Location = new System.Drawing.Point(16, 18); - this.lblMatches.Name = "lblMatches"; - this.lblMatches.Size = new System.Drawing.Size(56, 16); - this.lblMatches.TabIndex = 15; - this.lblMatches.Text = "Matches:"; - // - // MatchList - // - this.MatchList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MatchList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.MatchList.FullRowSelect = true; - this.MatchList.HideSelection = false; - this.MatchList.Location = new System.Drawing.Point(16, 40); - this.MatchList.MultiSelect = false; - this.MatchList.Name = "MatchList"; - this.MatchList.Size = new System.Drawing.Size(358, 368); - this.MatchList.TabIndex = 14; - this.MatchList.View = System.Windows.Forms.View.Details; - this.MatchList.DoubleClick += new System.EventHandler(this.MatchList_DoubleClick); - this.MatchList.SelectedIndexChanged += new System.EventHandler(this.MatchList_SelectedIndexChanged); - // - // columnHeader1 - // - this.columnHeader1.Text = "Title (Platform)"; - this.columnHeader1.Width = 247; - // - // columnHeader2 - // - this.columnHeader2.Text = "Relevance"; - this.columnHeader2.Width = 80; - // - // menuSaveDetails - // - this.menuSaveDetails.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuDataAndImages, - this.menuItem4, - this.menuData, - this.menuImages}); - // - // menuDataAndImages - // - this.menuDataAndImages.Index = 0; - this.menuDataAndImages.Text = "Save Data and download images"; - this.menuDataAndImages.Click += new System.EventHandler(this.menuDataAndImages_Click); - // - // menuItem4 - // - this.menuItem4.Index = 1; - this.menuItem4.Text = "-"; - // - // menuData - // - this.menuData.Index = 2; - this.menuData.Text = "Save Data only"; - this.menuData.Click += new System.EventHandler(this.menuData_Click); - // - // menuImages - // - this.menuImages.Index = 3; - this.menuImages.Text = "Download images only"; - this.menuImages.Click += new System.EventHandler(this.menuImages_Click); - // - // FileInfoScraperForm - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(752, 534); - this.Controls.Add(this.rightPanel); - this.Controls.Add(this.splitterVert); - this.Controls.Add(this.leftPanel); - this.Controls.Add(this.bottomPanel); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "FileInfoScraperForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Search fileinfo"; - this.bottomPanel.ResumeLayout(false); - this.progressPanel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.MinRelevanceNum)).EndInit(); - this.leftPanel.ResumeLayout(false); - this.rightPanel.ResumeLayout(false); - this.ResumeLayout(false); + SyncFileList(); + UpdateButtonStates(); + } + #endregion + + #region Properties / Helper Routines + + private FileItem GetSelectedFileItem() + { + if (listViewFileList.FocusedItem == null) return null; + if (listViewFileList.FocusedItem.Tag == null) return null; + + return listViewFileList.FocusedItem.Tag as FileItem; } + + private FileItemInfo GetSelectedMatchItem() + { + if (listViewMatchList.CheckedItems == null) return null; + if (listViewMatchList.CheckedItems[0] == null) return null; + if (listViewMatchList.CheckedItems[0].Tag == null) return null; + + return listViewMatchList.CheckedItems[0].Tag as FileItemInfo; + } + + private bool IsGoodMatch(FileItemInfo info) + { + bool result = (filterComboBox.Text == "") || (info.Platform.ToLower().IndexOf(filterComboBox.Text.ToLower()) == 0); + if (result) + { + result = (info.RelevanceNorm >= MinRelevanceNum.Value); + } + return result; + } + + private void SelectBestMatch(ListViewItem curItem) + { + if (curItem.Tag == null) return; + + FileItem file = curItem.Tag as FileItem; + if (file == null) return; + if (file.FileInfoList == null) return; + + foreach (FileItemInfo info in file.FileInfoList) + { + // check if + // - info is from platform, which is set in combobox + // - has minimum relevance + if (!IsGoodMatch(info)) continue; + + // if file has no favourite yet + if (file.FileInfoFavourite == null) + { + file.FileInfoFavourite = info; + continue; + } + + /* this needs adding the gameurl to database + // prevously selected infoitem + if (file.GameURL == info.GameURL) + { + file.FileInfoFavourite = info; + continue; + } + */ + + // file has already a favourite + // is info's relevance better than current favourite's relevance + if (info.RelevanceNorm > file.FileInfoFavourite.RelevanceNorm) + file.FileInfoFavourite = info; + } + + if (file.FileInfoFavourite != null) + { + curItem.SubItems[1].Text = String.Format("best: {0}%", file.FileInfoFavourite.RelevanceNorm); + } + else + { + curItem.SubItems[1].Text = "no match"; + } + } + #endregion + #region Display - public void Setup() + private void UpdateButtonStates() { - SyncListView(); - SyncFileLabel(); + // labels to update + groupBoxFileList.Text = String.Format("Files ({0} of {1} selected)", listViewFileList.CheckedItems.Count, listViewFileList.Items.Count); + + // button states to update + buttonStartSearch.Enabled = (listViewFileList.CheckedItems.Count > 0); + + if (!buttonStartSearch.Enabled) + buttonSaveSearch.Enabled = false; + + // when search is active, only cancel button should be enabled + groupBoxFileList.Enabled = (!isSearching); + groupBoxMatchList.Enabled = (!isSearching); + groupBoxFilter.Enabled = (!isSearching); + buttonStartSearch.Enabled = (!isSearching); + buttonSaveSearch.Enabled = (!isSearching); + buttonClose.Enabled = (!isSearching); + toolStripDropDownButton1.Enabled = isSearching; } - private void SyncListView() + private void ChangeFileSelection() { - if (m_CurApp == null) - return; + SyncMatchList(GetSelectedFileItem()); + } - FileList.BeginUpdate(); + private void SyncFileList() + { + if (m_CurApp == null) return; + + listViewFileList.BeginUpdate(); try { - FileList.Items.Clear(); + listViewFileList.Items.Clear(); // add all files foreach (FileItem file in m_CurApp.Files) { ListViewItem curItem = new ListViewItem(file.Title); + file.ToFileInfoFavourite(); curItem.Tag = file; if (!file.IsFolder) { - ListViewItem newItem = FileList.Items.Add(curItem); + ListViewItem newItem = listViewFileList.Items.Add(curItem); newItem.SubItems.Add("<unknown>"); } } } finally { - FileList.EndUpdate(); + listViewFileList.EndUpdate(); } } - private void button3_Click(object sender, EventArgs e) + private void SyncMatchList(FileItem file) { - if ((m_CurApp != null) && (filterComboBox.Text != "")) + listViewMatchList.BeginUpdate(); + try { - m_CurApp.SystemDefault = filterComboBox.Text; - m_CurApp.InsertOrUpdateSettings(); + listViewMatchList.Items.Clear(); + + if (file == null) return; + if (file.FileInfoList == null) return; + + foreach (FileItemInfo item in file.FileInfoList) + { + if (!IsGoodMatch(item)) continue; + + ListViewItem curItem = new ListViewItem(String.Format("{0} ({1})", item.Title, item.Platform)); + curItem.SubItems.Add(String.Format("{0}%", item.RelevanceNorm)); + curItem.Tag = item; + + // selected item? + if (file.FileInfoFavourite != null) + if (file.FileInfoFavourite == item) + { + curItem.Checked = true; + } + + listViewMatchList.Items.Add(curItem); + } } - this.Close(); + finally + { + listViewMatchList.EndUpdate(); + } } - void InitProgressBar(string msg) + private void InitProgressBar(string msg) { - progressPanel.Enabled = true; - progressBar.Value = 0; - if (FileList.CheckedItems.Count - 1 > 0) + toolStripProgressBar.Value = 0; + if (listViewFileList.CheckedItems.Count - 1 > 0) { - progressBar.Maximum = FileList.CheckedItems.Count - 1; + toolStripProgressBar.Maximum = listViewFileList.CheckedItems.Count - 1; } else { - progressBar.Maximum = 1; + toolStripProgressBar.Maximum = 1; } - progressBar.Step = 1; - progressStatusLabel.Text = msg; + toolStripProgressBar.Step = 1; + toolStripStatusLabel.Text = msg; mStartTime = (int)(DateTime.Now.Ticks / 10000); // reset timer! } - void StepProgressBar() + private void StepProgressBar() { string strTimeRemaining = ""; - progressBar.PerformStep(); - if (progressBar.Value > 1) + toolStripProgressBar.PerformStep(); + if (toolStripProgressBar.Value > 1) { int nTimeElapsed = ((int)(DateTime.Now.Ticks / 10000)) - mStartTime; - double TimePerItem = nTimeElapsed / progressBar.Value - 1; - int nTotalTime = (int)(progressBar.Maximum * TimePerItem); + double TimePerItem = nTimeElapsed / toolStripProgressBar.Value - 1; + int nTotalTime = (int)(toolStripProgressBar.Maximum * TimePerItem); int nTimeRemaining = nTotalTime - nTimeElapsed; int nSecondsRemaining = nTimeRemaining / 1000; int nMinutesRemaining = nSecondsRemaining / 60; @@ -686,292 +353,124 @@ strTimeRemaining = String.Format(" ({0}m {1}s remaining)", nMinutesRemaining, nSecondsRemaining); } - progressStatusLabel.Text = String.Format("Searching file {0} of {1} ", progressBar.Value, progressBar.Maximum + 1) + strTimeRemaining; + toolStripStatusLabel.Text = String.Format("Searching file {0} of {1} ", toolStripProgressBar.Value, toolStripProgressBar.Maximum + 1) + strTimeRemaining; } - void DeInitProgressBar(string msg) + private void DeInitProgressBar(string msg) { - progressPanel.Enabled = false; - progressStatusLabel.Text = msg; + toolStripStatusLabel.Text = msg; } - private void btnStartSearch_Click(object sender, EventArgs e) - { - int numberOfSearches = 0; - bool bSuccess = true; - InitProgressBar("Starting search"); - foreach (ListViewItem curItem in FileList.CheckedItems) - { - if (stopSearching) - break; - ListViewItem nextItem = null; - FileItem file = (FileItem)curItem.Tag; - if (file != null) - { - if (curItem.Index < FileList.Items.Count - 1) - { - nextItem = FileList.Items[curItem.Index + 1]; - } - else - { - nextItem = curItem; - } - nextItem.EnsureVisible(); - // if (!bSuccess) - // { - // curItem.SubItems[1].Text = String.Format("waiting for reconnection..."); - // System.Threading.Thread.Sleep(5126); - // } - numberOfSearches = numberOfSearches + 1; - if (numberOfSearches > 20) - { - curItem.SubItems[1].Text = String.Format("waiting..."); - System.Threading.Thread.Sleep(20000); - System.Windows.Forms.Application.DoEvents(); - numberOfSearches = 0; - } - curItem.SubItems[1].Text = String.Format("searching..."); - curItem.Font = new Font(curItem.Font, curItem.Font.Style | FontStyle.Bold); - System.Windows.Forms.Application.DoEvents(); - bSuccess = file.FindFileInfo(curItem.Text, ScraperType.ALLGAME); - curItem.SubItems[1].Text = String.Format("{0} matches", file.FileInfoList.Count); - StepProgressBar(); - buttonSelectBestMatch.Enabled = true; - System.Windows.Forms.Application.DoEvents(); - } - } - ChangeFileSelection(); - if (stopSearching) - { - DeInitProgressBar("Search aborted"); - } - else - { - DeInitProgressBar("Search finished"); - } - stopSearching = false; - } + #endregion + #region ControlEvents - private FileItem GetSelectedFileItem() + #region Lists + + private void listViewFileList_SelectedIndexChanged(object sender, EventArgs e) { - FileItem res = null; - if (FileList.FocusedItem != null) - { - if (FileList.FocusedItem.Tag != null) - { - res = (FileItem)FileList.FocusedItem.Tag; - } - } - return res; + ChangeFileSelection(); } - private FileItemInfo GetSelectedMatchItem() + private void listViewFileList_ItemChecked(object sender, ItemCheckedEventArgs e) { - FileItemInfo res = null; - if (MatchList.SelectedItems != null) - { - if (MatchList.SelectedItems[0] != null) - { - if (MatchList.SelectedItems[0].Tag != null) - { - res = (FileItemInfo)MatchList.SelectedItems[0].Tag; - } - } - } - return res; + UpdateButtonStates(); } - - private bool IsGoodMatch(FileItemInfo info) + private void listViewMatchList_ItemCheck(object sender, ItemCheckEventArgs e) { - bool result = (filterComboBox.Text == "") || (info.Platform.ToLower().IndexOf(filterComboBox.Text.ToLower()) == 0); - if (result) + if (e.NewValue == CheckState.Checked) { - result = (info.RelevanceNorm >= MinRelevanceNum.Value); + if (listViewMatchList.CheckedItems == null) return; + foreach (ListViewItem item in listViewMatchList.CheckedItems) + if (item.Index != e.Index) + item.Checked = false; } - return result; } - private void SyncMatchesList(FileItem file) + private void listViewMatchList_ItemChecked(object sender, ItemCheckedEventArgs e) { - LaunchURLButton.Enabled = false; - MatchList.BeginUpdate(); - try - { - MatchList.Items.Clear(); - if (file != null) - { - if (file.FileInfoList != null) - { - foreach (FileItemInfo item in file.FileInfoList) - { - if (IsGoodMatch(item)) - { - ListViewItem curItem = new ListViewItem(String.Format("{0} ({1})", item.Title, item.Platform)); - curItem.SubItems.Add(String.Format("{0}%", item.RelevanceNorm)); - // curItem.SubItems[1].Text = String.Format("{0}%", item.Relevance); - curItem.Tag = item; - curItem = MatchList.Items.Add(curItem); - // selected item? - if ((file.FileInfoFavourite != null) && (file.FileInfoFavourite == item)) - { - curItem.Selected = true; - LaunchURLButton.Enabled = true; - } - } - } - } - } - } - finally - { - MatchList.EndUpdate(); - } + if (e.Item.Checked == false) return; - } + FileItem file = GetSelectedFileItem(); + if (file == null) return; + if (e.Item.Tag == null) return; + FileItemInfo info = e.Item.Tag as FileItemInfo; + if (info == null) return; - private void ChangeFileSelection() - { - FileItem file = GetSelectedFileItem(); - SyncMatchesList(file); + file.FileInfoFavourite = info; + buttonSaveSearch.Enabled = true; + listViewFileList.FocusedItem.SubItems[1].Text = String.Format("best: {0}%", file.FileInfoFavourite.RelevanceNorm); } - private void FileList_SelectedIndexChanged(object sender, EventArgs e) + private void listViewMatchList_SelectedIndexChanged(object sender, EventArgs e) { - ChangeFileSelection(); + if (listViewMatchList.SelectedItems.Count == 0) return; + if (listViewMatchList.SelectedItems[0].Tag == null) return; + FileItemInfo info = listViewMatchList.SelectedItems[0].Tag as FileItemInfo; + if (info == null) return; + + info.LaunchURL(); } - private void allGameLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void checkboxFileList_CheckedChanged(object sender, EventArgs e) { - if (allGameLink.Text == null) - return; - if (allGameLink.Text.Length > 0) + if (checkboxFileList.Checked) { - ProcessStartInfo sInfo = new ProcessStartInfo(allGameLink.Text); - Process.Start(sInfo); + foreach (ListViewItem curItem in listViewFileList.Items) + curItem.Checked = true; } + else + { + foreach (ListViewItem curItem in listViewFileList.Items) + curItem.Checked = false; + } + UpdateButtonStates(); } - private void LaunchSelectedMatchURL() - { - FileItemInfo info = GetSelectedMatchItem(); - if (info == null) - return; - info.LaunchURL(); - } + #endregion + #region Buttons - private void MatchList_DoubleClick(object sender, EventArgs e) + private void btnStartSearch_Click(object sender, EventArgs e) { - LaunchSelectedMatchURL(); + SearchStart(); } - private void checkAllButton_Click(object sender, EventArgs e) + private void btnSaveSearch_Click(object sender, EventArgs e) { - foreach (ListViewItem curItem in FileList.Items) - { - curItem.Checked = true; - } - btnStartSearch.Enabled = (FileList.CheckedItems.Count > 0); - SyncFileLabel(); + menuSaveDetails.Show(buttonSaveSearch, new Point(0, buttonSaveSearch.Height)); } - private void uncheckAllButton_Click(object sender, EventArgs e) + private void cancelSearchToolStripMenuItem_Click(object sender, EventArgs e) { - foreach (ListViewItem curItem in FileList.Items) - { - curItem.Checked = false; - } - btnStartSearch.Enabled = false; - buttonSelectBestMatch.Enabled = false; - btnSaveSearch.Enabled = false; - SyncFileLabel(); + stopSearching = true; } - private void MatchList_SelectedIndexChanged(object sender, EventArgs e) + private void buttonClose_Click(object sender, EventArgs e) { - FileItem file = GetSelectedFileItem(); - if (file == null) - return; - - if (MatchList.SelectedIndices.Count > 0) + if ((m_CurApp != null) && (filterComboBox.Text != "")) { - FileItemInfo info = GetSelectedMatchItem(); - file.FileInfoFavourite = info; - LaunchURLButton.Enabled = true; - btnSaveSearch.Enabled = true; - FileList.FocusedItem.SubItems[1].Text = String.Format("best: {0}%", file.FileInfoFavourite.RelevanceNorm); + m_CurApp.SystemDefault = filterComboBox.Text; + //m_CurApp.Write(); } - else - { - file.FileInfoFavourite = null; - LaunchURLButton.Enabled = false; - } + this.Close(); } - private void btnSaveSearch_Click(object sender, EventArgs e) + private void allGameLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - menuSaveDetails.Show(btnSaveSearch, new Point(0, btnSaveSearch.Height)); - } + if (linkLabelAllGame.Text == null) return; - void SaveSearch(ScraperSaveType saveType) - { - int numberOfSearches = 0; - InitProgressBar("Starting search"); - ListViewItem nextItem = null; - foreach (ListViewItem curItem in FileList.CheckedItems) + if (linkLabelAllGame.Text.Length > 0) { - if (stopSearching) - break; - FileItem file = (FileItem)curItem.Tag; - if (file != null) - { - if (curItem.Index < FileList.Items.Count - 1) - { - nextItem = FileList.Items[curItem.Index + 1]; - } - else - { - nextItem = curItem; - } - nextItem.EnsureVisible(); - StepProgressBar(); - if (file.FileInfoFavourite != null) - { - numberOfSearches++; - numberOfSearches = numberOfSearches + 1; - if (numberOfSearches > 20) - { - curItem.SubItems[1].Text = String.Format("waiting..."); - System.Windows.Forms.Application.DoEvents(); - System.Threading.Thread.Sleep(20000); - numberOfSearches = 0; - } - curItem.SubItems[1].Text = String.Format("<searching...>"); - System.Windows.Forms.Application.DoEvents(); - file.FindFileInfoDetail(m_CurApp, file.FileInfoFavourite, ScraperType.ALLGAME, saveType); - if ((saveType == ScraperSaveType.DataAndImages) || (saveType == ScraperSaveType.Data)) - { - file.SaveFromFileInfoFavourite(); - } - curItem.SubItems[1].Text = String.Format("<saved>"); - System.Windows.Forms.Application.DoEvents(); - } - } + ProcessStartInfo sInfo = new ProcessStartInfo(linkLabelAllGame.Text); + Process.Start(sInfo); } - if (stopSearching) - { - DeInitProgressBar("Search aborted"); - } - else - { - DeInitProgressBar("Search finished"); - } - stopSearching = false; } + #endregion + private void filterComboBox_SelectedIndexChanged(object sender, EventArgs e) { ChangeFileSelection(); @@ -991,69 +490,17 @@ ChangeFileSelection(); } - private void buttonSelectBestMatch_Click(object sender, EventArgs e) - { - foreach (ListViewItem curItem in FileList.CheckedItems) - { - FileItem file = (FileItem)curItem.Tag; - if (file != null) - { - if (file.FileInfoList != null) - { - file.FileInfoFavourite = null; - foreach (FileItemInfo item in file.FileInfoList) - { - if (IsGoodMatch(item)) - { - btnSaveSearch.Enabled = true; - file.FileInfoFavourite = item; - break; - } - } - if (file.FileInfoFavourite != null) - { - curItem.SubItems[1].Text = String.Format("best: {0}%", file.FileInfoFavourite.RelevanceNorm); - } - else - { - curItem.SubItems[1].Text = "no match"; - } - } - } - } - ChangeFileSelection(); - } - private void MinRelevanceNum_ValueChanged(object sender, EventArgs e) { ChangeFileSelection(); } - private void LaunchURLButton_Click(object sender, EventArgs e) - { - LaunchSelectedMatchURL(); - } + #region Menus - private void FileList_MouseUp(object sender, MouseEventArgs e) - { - SyncButtons(); - } - - void SyncButtons() - { - btnStartSearch.Enabled = (FileList.CheckedItems.Count > 0); - if (!btnStartSearch.Enabled) - { - buttonSelectBestMatch.Enabled = false; - btnSaveSearch.Enabled = false; - } - SyncFileLabel(); - } - private void mnuCheckWithoutImages_Click(object sender, EventArgs e) { FileItem curFile; - foreach (ListViewItem curItem in FileList.Items) + foreach (ListViewItem curItem in listViewFileList.Items) { curFile = (FileItem)curItem.Tag; if (curFile != null) @@ -1065,14 +512,13 @@ curItem.Checked = false; } } - btnStartSearch.Enabled = (FileList.CheckedItems.Count > 0); - SyncFileLabel(); + buttonStartSearch.Enabled = (listViewFileList.CheckedItems.Count > 0); + UpdateButtonStates(); } - private void mnuCheckWithoutOverview_Click(object sender, EventArgs e) { FileItem curFile; - foreach (ListViewItem curItem in FileList.Items) + foreach (ListViewItem curItem in listViewFileList.Items) { curFile = (FileItem)curItem.Tag; if (curFile != null) @@ -1084,42 +530,672 @@ curItem.Checked = false; } } - btnStartSearch.Enabled = (FileList.CheckedItems.Count > 0); - SyncFileLabel(); + buttonStartSearch.Enabled = (listViewFileList.CheckedItems.Count > 0); + UpdateButtonStates(); } - - private void SyncFileLabel() + + private void menuDataAndImages_Click(object sender, EventArgs e) { - lblFiles.Text = String.Format("Files: ({0} of {1} selected)", FileList.CheckedItems.Count, FileList.Items.Count); + saveType = ScraperSaveType.DataAndImages; + SearchSave(); } + private void menuData_Click(object sender, EventArgs e) + { + saveType = ScraperSaveType.Data; + SearchSave(); + } + private void menuImages_Click(object sender, EventArgs e) + { + saveType = ScraperSaveType.Images; + SearchSave(); + } - private void FileList_AfterLabelEdit(object sender, LabelEditEventArgs e) + #endregion + + #endregion + + #region Threads + + private void SearchStart() { - FileItem curItem = GetSelectedFileItem(); - if (curItem == null) - return; - curItem.TitleOptimized = e.Label; + Thread thread = new Thread(new ThreadStart(SearchStartThread)); + thread.Priority = ThreadPriority.BelowNormal; + thread.Name = "MyPrograms SearchStart"; + thread.Start(); } - private void cancelButton_Click(object sender, EventArgs e) + private void SearchStartThread() { - stopSearching = true; + isSearching = true; + UpdateButtonStates(); + + int numberOfSearches = 0; + bool bSuccess = true; + InitProgressBar("Starting search"); + foreach (ListViewItem curItem in listViewFileList.CheckedItems) + { + if (stopSearching) break; + if (curItem.Tag == null) continue; + + FileItem file = curItem.Tag as FileItem; + if (file == null) continue; + + ListViewItem nextItem = null; + + if (curItem.Index < listViewFileList.Items.Count - 1) + { + nextItem = listViewFileList.Items[curItem.Index + 1]; + } + else + { + nextItem = curItem; + } + nextItem.EnsureVisible(); + // if (!bSuccess) + // { + // curItem.SubItems[1].Text = String.Format("waiting for reconnection..."); + // System.Threading.Thread.Sleep(5126); + // } + numberOfSearches = numberOfSearches + 1; + if (numberOfSearches > 20) + { + curItem.SubItems[1].Text = String.Format("waiting..."); + System.Threading.Thread.Sleep(20000); + System.Windows.Forms.Application.DoEvents(); + numberOfSearches = 0; + } + curItem.SubItems[1].Text = String.Format("searching..."); + curItem.Font = new Font(curItem.Font, curItem.Font.Style | FontStyle.Bold); + System.Windows.Forms.Application.DoEvents(); + bSuccess = file.FindFileInfo(file.Title, ScraperType.ALLGAME); + + SelectBestMatch(curItem); + + StepProgressBar(); + System.Windows.Forms.Application.DoEvents(); + } + ChangeFileSelection(); + if (stopSearching) + { + DeInitProgressBar("Search aborted"); + } + else + { + DeInitProgressBar("Search finished"); + } + + stopSearching = false; + isSearching = false; + UpdateButtonStates(); } - private void menuDataAndImages_Click(object sender, EventArgs e) + private void SearchSave() { - SaveSearch(ScraperSaveType.DataAndImages); + Thread thread = new Thread(new ThreadStart(SearchSaveThread)); + thread.Priority = ThreadPriority.BelowNormal; + thread.Name = "MyPrograms SearchSave"; + thread.Start(); } - private void menuData_Click(object sender, EventArgs e) + private void SearchSaveThread() { - SaveSearch(ScraperSaveType.Data); + isSearching = true; + UpdateButtonStates(); + + int numberOfSearches = 0; + InitProgressBar("Starting search"); + ListViewItem nextItem = null; + + foreach (ListViewItem curItem in listViewFileList.CheckedItems) + { + if (stopSearching) + break; + FileItem file = (FileItem)curItem.Tag; + + if (file == null) + continue; + + if (curItem.Index < listViewFileList.Items.Count - 1) + { + nextItem = listViewFileList.Items[curItem.Index + 1]; + } + else + { + nextItem = curItem; + } + nextItem.EnsureVisible(); + StepProgressBar(); + if (file.FileInfoFavourite != null) + { + numberOfSearches++; + numberOfSearches = numberOfSearches + 1; + if (numberOfSearches > 20) + { + curItem.SubItems[1].Text = String.Format("waiting..."); + System.Windows.Forms.Application.DoEvents(); + System.Threading.Thread.Sleep(20000); + numberOfSearches = 0; + } + curItem.SubItems[1].Text = String.Format("<searching...>"); + System.Windows.Forms.Application.DoEvents(); + file.FindFileInfoDetail(m_CurApp, file.FileInfoFavourite, ScraperType.ALLGAME, saveType); + if ((saveType == ScraperSaveType.DataAndImages) || (saveType == ScraperSaveType.Data)) + { + file.SaveFromFileInfoFavourite(); + } + curItem.SubItems[1].Text = String.Format("<saved>"); + System.Windows.Forms.Application.DoEvents(); + } + } + if (stopSearching) + { + DeInitProgressBar("Search aborted"); + } + else + { + DeInitProgressBar("Search finished"); + } + + stopSearching = false; + isSearching = false; + UpdateButtonStates(); } - private void menuImages_Click(object sender, EventArgs e) + #endregion + + #region Windows Form Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() { - SaveSearch(ScraperSaveType.Images); + this.components = new System.ComponentModel.Container(); + this.bottomPanel = new System.Windows.Forms.Panel(); + this.label2 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.groupBoxFilter = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.labelPlatform = new MediaPortal.UserInterface.Controls.MPLabel(); + this.filterComboBox = new MediaPortal.UserInterface.Controls.MPComboBox(); + this.ResetFilterButton = new MediaPortal.UserInterface.Controls.MPButton(); + this.MinRelevanceNum = new System.Windows.Forms.NumericUpDown(); + this.label1 = new MediaPortal.UserInterface.Controls.MPLabel(); + this.linkLabelAllGame = new System.Windows.Forms.LinkLabel(); + this.buttonClose = new MediaPortal.UserInterface.Controls.MPButton(); + this.buttonSaveSearch = new MediaPortal.UserInterface.Controls.MPButton(); + this.buttonStartSearch = new MediaPortal.UserInterface.Controls.MPButton(); + this.listViewFileList = new MediaPortal.UserInterface.Controls.MPListView(); + this.FileTitle = new System.Windows.Forms.ColumnHeader(); + this.status = new System.Windows.Forms.ColumnHeader(); + this.menuFileList = new System.Windows.Forms.ContextMenu(); + this.mnuCheckWithoutImages = new System.Windows.Forms.MenuItem(); + this.mnuCheckWithoutOverview = new System.Windows.Forms.MenuItem(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.menuSaveDetails = new System.Windows.Forms.ContextMenu(); + this.menuDataAndImages = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); + this.menuData = new System.Windows.Forms.MenuItem(); + this.menuImages = new System.Windows.Forms.MenuItem(); + this.groupBoxMatchList = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.labelLaunchUrlInfo = new MediaPortal.UserInterface.Controls.MPLabel(); + this.listViewMatchList = new MediaPortal.UserInterface.Controls.MPListView(); + this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); + this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); + this.groupBoxFileList = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.checkboxFileList = new MediaPortal.UserInterface.Controls.MPCheckBox(); + this.splitContainer1 = new System.Windows.Forms.SplitCo... [truncated message content] |