Fixed cross-threading ness (more thread safety - oops :P)

-- This fixed the VC menu issues.
This commit is contained in:
gb.luke 2010-07-01 00:40:30 +00:00
parent 85bdcaa1cf
commit eb179b0321
4 changed files with 43 additions and 12 deletions

View File

@ -136,6 +136,7 @@
this.ProxyPwdBox = new System.Windows.Forms.TextBox(); this.ProxyPwdBox = new System.Windows.Forms.TextBox();
this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = 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.dlprogress = new wyDay.Controls.Windows7ProgressBar();
this.databaseStrip.SuspendLayout(); this.databaseStrip.SuspendLayout();
this.tmdgpbox.SuspendLayout(); this.tmdgpbox.SuspendLayout();
@ -313,7 +314,7 @@
this.RegionCodesList}); this.RegionCodesList});
this.databaseStrip.Name = "databaseStrip"; this.databaseStrip.Name = "databaseStrip";
this.databaseStrip.ShowItemToolTips = false; this.databaseStrip.ShowItemToolTips = false;
this.databaseStrip.Size = new System.Drawing.Size(155, 120); this.databaseStrip.Size = new System.Drawing.Size(155, 142);
// //
// SystemMenuList // SystemMenuList
// //
@ -348,6 +349,7 @@
// //
// C64MenuList // C64MenuList
// //
this.C64MenuList.DropDown = this.C64MenuListDrop;
this.C64MenuList.Name = "C64MenuList"; this.C64MenuList.Name = "C64MenuList";
this.C64MenuList.Size = new System.Drawing.Size(194, 22); this.C64MenuList.Size = new System.Drawing.Size(194, 22);
this.C64MenuList.Text = "Commodore 64"; this.C64MenuList.Text = "Commodore 64";
@ -883,7 +885,7 @@
this.toolStripSeparator2, this.toolStripSeparator2,
this.updateDatabaseToolStripMenuItem}); this.updateDatabaseToolStripMenuItem});
this.extrasStrip.Name = "extrasStrip"; this.extrasStrip.Name = "extrasStrip";
this.extrasStrip.Size = new System.Drawing.Size(242, 216); this.extrasStrip.Size = new System.Drawing.Size(242, 194);
// //
// loadInfoFromTMDToolStripMenuItem // loadInfoFromTMDToolStripMenuItem
// //
@ -1164,6 +1166,12 @@
this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); 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 // dlprogress
// //
this.dlprogress.ContainerControl = this; this.dlprogress.ContainerControl = this;
@ -1343,6 +1351,7 @@
private System.Windows.Forms.ToolStripMenuItem getCommonKeyMenuItem; private System.Windows.Forms.ToolStripMenuItem getCommonKeyMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip C64MenuListDrop;
} }
} }

View File

@ -11,6 +11,8 @@ using System.Threading;
using System.Text; using System.Text;
using wyDay.Controls; using wyDay.Controls;
using System.Diagnostics;
namespace NUS_Downloader namespace NUS_Downloader
{ {
@ -20,10 +22,13 @@ namespace NUS_Downloader
const string DSiNUSURL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; const string DSiNUSURL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/";
// TODO: Always remember to change version! // TODO: Always remember to change version!
string version = "v1.5 (Beta)"; string version = "v1.5a (Beta)";
WebClient generalWC = new WebClient(); WebClient generalWC = new WebClient();
static RijndaelManaged rijndaelCipher; static RijndaelManaged rijndaelCipher;
static bool dsidecrypt = false; static bool dsidecrypt = false;
// Cross-thread Windows Formsing
delegate void AddToolStripItemToStripCallback(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); //TODO
// Images do not compare unless globalized... // Images do not compare unless globalized...
Image green = Properties.Resources.bullet_green; Image green = Properties.Resources.bullet_green;
@ -1526,6 +1531,7 @@ namespace NUS_Downloader
WriteStatus("NUS Downloader (NUSD)"); WriteStatus("NUS Downloader (NUSD)");
WriteStatus("You are running version: " + version); WriteStatus("You are running version: " + version);
WriteStatus("This application created by WB3000"); WriteStatus("This application created by WB3000");
WriteStatus("Various sections contributed by lukegb");
WriteStatus(""); WriteStatus("");
string currentdir = Application.StartupPath; string currentdir = Application.StartupPath;
if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false) if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false)
@ -1884,10 +1890,21 @@ namespace NUS_Downloader
/// <param name="additionitem">The additionitem.</param> /// <param name="additionitem">The additionitem.</param>
/// <param name="attributes">The attributes.</param> /// <param name="attributes">The attributes.</param>
void AddToolStripItemToStrip(int type, ToolStripMenuItem additionitem, XmlAttributeCollection 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... // Deal with VC list depth...
if (type == 2) if (type == 2)
{ {
Debug.WriteLine("Adding:");
Debug.WriteLine(additionitem);
switch (attributes[0].Value) switch (attributes[0].Value)
{ {
case "C64": case "C64":
@ -1926,7 +1943,7 @@ namespace NUS_Downloader
default: default:
break; break;
} }
additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(wwitem_regionclicked); // additionitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(wwitem_regionclicked);
} }
else else
{ {

View File

@ -112,18 +112,21 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="NUSDownloader.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="NUSDownloader.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="databaseStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="databaseStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>159, 17</value> <value>159, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <metadata name="C64MenuListDrop.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>394, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="button12.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="button12.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m
@ -206,7 +209,7 @@
c3rr+88Wyom3k23LfyYpTu77C4h89ngRLmtIAAAAAElFTkSuQmCC c3rr+88Wyom3k23LfyYpTu77C4h89ngRLmtIAAAAAElFTkSuQmCC
</value> </value>
</data> </data>
<metadata name="extrasStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="extrasStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>285, 17</value> <value>285, 17</value>
</metadata> </metadata>
<data name="radioButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="radioButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

View File

@ -95,7 +95,9 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="app.config" /> <None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>