From eb179b032165bb330dbe55d92d61b5007f56b729 Mon Sep 17 00:00:00 2001 From: "gb.luke" Date: Thu, 1 Jul 2010 00:40:30 +0000 Subject: [PATCH] Fixed cross-threading ness (more thread safety - oops :P) -- This fixed the VC menu issues. --- NUS Downloader/Form1.Designer.cs | 13 +++++++++++-- NUS Downloader/Form1.cs | 23 ++++++++++++++++++++--- NUS Downloader/Form1.resx | 15 +++++++++------ NUS Downloader/NUS Downloader.csproj | 4 +++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/NUS Downloader/Form1.Designer.cs b/NUS Downloader/Form1.Designer.cs index a99946c..eaffb1d 100644 --- a/NUS Downloader/Form1.Designer.cs +++ b/NUS Downloader/Form1.Designer.cs @@ -136,6 +136,7 @@ this.ProxyPwdBox = new System.Windows.Forms.TextBox(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.C64MenuListDrop = new System.Windows.Forms.ContextMenuStrip(this.components); this.dlprogress = new wyDay.Controls.Windows7ProgressBar(); this.databaseStrip.SuspendLayout(); this.tmdgpbox.SuspendLayout(); @@ -313,7 +314,7 @@ this.RegionCodesList}); this.databaseStrip.Name = "databaseStrip"; this.databaseStrip.ShowItemToolTips = false; - this.databaseStrip.Size = new System.Drawing.Size(155, 120); + this.databaseStrip.Size = new System.Drawing.Size(155, 142); // // SystemMenuList // @@ -348,6 +349,7 @@ // // C64MenuList // + this.C64MenuList.DropDown = this.C64MenuListDrop; this.C64MenuList.Name = "C64MenuList"; this.C64MenuList.Size = new System.Drawing.Size(194, 22); this.C64MenuList.Text = "Commodore 64"; @@ -883,7 +885,7 @@ this.toolStripSeparator2, this.updateDatabaseToolStripMenuItem}); this.extrasStrip.Name = "extrasStrip"; - this.extrasStrip.Size = new System.Drawing.Size(242, 216); + this.extrasStrip.Size = new System.Drawing.Size(242, 194); // // loadInfoFromTMDToolStripMenuItem // @@ -1164,6 +1166,12 @@ this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); // + // C64MenuListDrop + // + this.C64MenuListDrop.Name = "C64MenuListDrop"; + this.C64MenuListDrop.OwnerItem = this.C64MenuList; + this.C64MenuListDrop.Size = new System.Drawing.Size(153, 26); + // // dlprogress // this.dlprogress.ContainerControl = this; @@ -1343,6 +1351,7 @@ private System.Windows.Forms.ToolStripMenuItem getCommonKeyMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip C64MenuListDrop; } } diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index d066225..2ab9956 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -11,6 +11,8 @@ using System.Threading; using System.Text; using wyDay.Controls; +using System.Diagnostics; + namespace NUS_Downloader { @@ -20,10 +22,13 @@ namespace NUS_Downloader const string DSiNUSURL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; // TODO: Always remember to change version! - string version = "v1.5 (Beta)"; + string version = "v1.5a (Beta)"; WebClient generalWC = new WebClient(); static RijndaelManaged rijndaelCipher; static bool dsidecrypt = false; + + // Cross-thread Windows Formsing + delegate void AddToolStripItemToStripCallback(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); //TODO // Images do not compare unless globalized... Image green = Properties.Resources.bullet_green; @@ -1526,6 +1531,7 @@ namespace NUS_Downloader WriteStatus("NUS Downloader (NUSD)"); WriteStatus("You are running version: " + version); WriteStatus("This application created by WB3000"); + WriteStatus("Various sections contributed by lukegb"); WriteStatus(""); string currentdir = Application.StartupPath; if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false) @@ -1884,10 +1890,21 @@ namespace NUS_Downloader /// The additionitem. /// The attributes. void AddToolStripItemToStrip(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes) - { + { + Debug.WriteLine("Adding item..."); + // Check if thread-safe + if (this.InvokeRequired) + { + Debug.WriteLine("InvokeRequired..."); + AddToolStripItemToStripCallback atsitsc = new AddToolStripItemToStripCallback(AddToolStripItemToStrip); + this.Invoke(atsitsc, new object[] { type, additionitem, attributes }); + return; + } // Deal with VC list depth... if (type == 2) { + Debug.WriteLine("Adding:"); + Debug.WriteLine(additionitem); switch (attributes[0].Value) { case "C64": @@ -1926,7 +1943,7 @@ namespace NUS_Downloader default: break; } - additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(wwitem_regionclicked); + // additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(wwitem_regionclicked); } else { diff --git a/NUS Downloader/Form1.resx b/NUS Downloader/Form1.resx index 5157dcf..cf53ee1 100644 --- a/NUS Downloader/Form1.resx +++ b/NUS Downloader/Form1.resx @@ -112,18 +112,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + 159, 17 - + + 394, 17 + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m @@ -206,7 +209,7 @@ c3rr+88Wyom3k23LfyYpTu77C4h89ngRLmtIAAAAAElFTkSuQmCC - + 285, 17 diff --git a/NUS Downloader/NUS Downloader.csproj b/NUS Downloader/NUS Downloader.csproj index 417a570..077c874 100644 --- a/NUS Downloader/NUS Downloader.csproj +++ b/NUS Downloader/NUS Downloader.csproj @@ -95,7 +95,9 @@ Resources.resx True - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs