diff --git a/SBoxModList.suo b/SBoxModList.suo index 739a058..f76056b 100644 Binary files a/SBoxModList.suo and b/SBoxModList.suo differ diff --git a/SBoxModList/ClassDiagram1.cd b/SBoxModList/ClassDiagram1.cd new file mode 100644 index 0000000..1d49cb2 --- /dev/null +++ b/SBoxModList/ClassDiagram1.cd @@ -0,0 +1,11 @@ + + + + + + AAAAwAAAACiAABAAAEKAAAACIAACAAAAAEAAAEAAAAI= + Form1.cs + + + + \ No newline at end of file diff --git a/SBoxModList/Form1.Designer.cs b/SBoxModList/Form1.Designer.cs index 279236c..48b5fb5 100644 --- a/SBoxModList/Form1.Designer.cs +++ b/SBoxModList/Form1.Designer.cs @@ -30,7 +30,12 @@ private void InitializeComponent() { this.btnOpen = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); + this.txtOutRAW = new System.Windows.Forms.RichTextBox(); this.txtOut = new System.Windows.Forms.RichTextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.btnSName = new System.Windows.Forms.Button(); + this.btnSID = new System.Windows.Forms.Button(); + this.lblLoad = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btnOpen @@ -48,9 +53,20 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(110, 71); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(47, 13); + this.label1.Size = new System.Drawing.Size(76, 13); this.label1.TabIndex = 2; - this.label1.Text = "Mod List"; + this.label1.Text = "Mod List RAW"; + // + // txtOutRAW + // + this.txtOutRAW.ForeColor = System.Drawing.SystemColors.ControlText; + this.txtOutRAW.Location = new System.Drawing.Point(23, 87); + this.txtOutRAW.Name = "txtOutRAW"; + this.txtOutRAW.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; + this.txtOutRAW.Size = new System.Drawing.Size(262, 179); + this.txtOutRAW.TabIndex = 3; + this.txtOutRAW.Text = ""; + this.txtOutRAW.WordWrap = false; // // txtOut // @@ -58,21 +74,63 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txtOut.ForeColor = System.Drawing.SystemColors.ControlText; - this.txtOut.Location = new System.Drawing.Point(12, 141); + this.txtOut.Location = new System.Drawing.Point(12, 327); this.txtOut.Name = "txtOut"; this.txtOut.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; - this.txtOut.Size = new System.Drawing.Size(462, 158); - this.txtOut.TabIndex = 3; + this.txtOut.Size = new System.Drawing.Size(466, 248); + this.txtOut.TabIndex = 4; this.txtOut.Text = ""; this.txtOut.WordWrap = false; this.txtOut.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.txtOut_LinkClicked); // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(113, 308); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.TabIndex = 5; + this.label2.Text = "Mod Details"; + // + // btnSName + // + this.btnSName.Location = new System.Drawing.Point(196, 287); + this.btnSName.Name = "btnSName"; + this.btnSName.Size = new System.Drawing.Size(102, 23); + this.btnSName.TabIndex = 6; + this.btnSName.Text = "Sort By Name"; + this.btnSName.UseVisualStyleBackColor = true; + this.btnSName.Click += new System.EventHandler(this.btnSName_Click); + // + // btnSID + // + this.btnSID.Location = new System.Drawing.Point(323, 287); + this.btnSID.Name = "btnSID"; + this.btnSID.Size = new System.Drawing.Size(75, 23); + this.btnSID.TabIndex = 7; + this.btnSID.Text = "Sort By ID"; + this.btnSID.UseVisualStyleBackColor = true; + this.btnSID.Click += new System.EventHandler(this.btnSID_Click); + // + // lblLoad + // + this.lblLoad.AutoSize = true; + this.lblLoad.Location = new System.Drawing.Point(209, 33); + this.lblLoad.Name = "lblLoad"; + this.lblLoad.Size = new System.Drawing.Size(0, 13); + this.lblLoad.TabIndex = 8; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(486, 299); + this.ClientSize = new System.Drawing.Size(490, 587); + this.Controls.Add(this.lblLoad); + this.Controls.Add(this.btnSID); + this.Controls.Add(this.btnSName); + this.Controls.Add(this.label2); this.Controls.Add(this.txtOut); + this.Controls.Add(this.txtOutRAW); this.Controls.Add(this.label1); this.Controls.Add(this.btnOpen); this.Name = "Form1"; @@ -86,7 +144,12 @@ private void InitializeComponent() private System.Windows.Forms.Button btnOpen; private System.Windows.Forms.Label label1; + private System.Windows.Forms.RichTextBox txtOutRAW; private System.Windows.Forms.RichTextBox txtOut; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnSName; + private System.Windows.Forms.Button btnSID; + private System.Windows.Forms.Label lblLoad; } } diff --git a/SBoxModList/Form1.cs b/SBoxModList/Form1.cs index a7c01d4..0360e8e 100644 --- a/SBoxModList/Form1.cs +++ b/SBoxModList/Form1.cs @@ -12,12 +12,24 @@ using System.Net; using System.Diagnostics; using System.Text.RegularExpressions; +using System.Linq; namespace SBoxModList { + + public class WebTimeout : WebClient + { + protected override WebRequest GetWebRequest(Uri uri) + { + WebRequest w = base.GetWebRequest(uri); + w.Timeout = 5000; + return w; + } + } public partial class Form1 : Form { + OpenFileDialog ofd = new OpenFileDialog(); - WebClient web = new WebClient(); + WebTimeout web = new WebTimeout(); XPathDocument SBCFile; XPathNavigator nav; XPathNodeIterator modListIt; @@ -28,22 +40,106 @@ public Form1() InitializeComponent(); } + public struct ModInfo + { + public String ID; + public String title; + public String URL; + } + public List ModList = new List(); + + private void button1_Click(object sender, EventArgs e) { + + try { if (ofd.ShowDialog() == DialogResult.OK) { - + lblLoad.Text = "Loading: "; String fName = ofd.FileName; String sFName = ofd.FileName; SBCFile = new XPathDocument(fName); nav = SBCFile.CreateNavigator(); modListIt = nav.Select("//ModItem/PublishedFileId"); + + /* + txtOutRAW.Clear(); + + while (modListIt.MoveNext()) + { + + txtOutRAW.AppendText(modListIt.Current.InnerXml + "\r\n"); + + + } + */ + + + + ModList.Clear(); + + while (modListIt.MoveNext()) + { + ModInfo modInfo = new ModInfo(); + modInfo.ID = modListIt.Current.InnerXml; + modInfo.URL = "http://steamcommunity.com/sharedfiles/filedetails/?id=" + modInfo.ID; + int failcount = 0; + do{ + try + { + + string workshopPage = web.DownloadString(modInfo.URL); + System.Threading.Thread.Sleep(500); + modInfo.title = Regex.Match(workshopPage, @"\]*\>\s*(?[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; + modInfo.title = modInfo.title.Replace("Steam Workshop :: ", ""); + if (failcount > 0) failcount = 0; + + } + catch (Exception) + { + modInfo.title = "URL Timed Out"; + failcount++; + } + }while(failcount>0&&failcount<4); + ModList.Add(modInfo); + lblLoad.Text += "|"; + if(lblLoad.Text.TakeWhile(c => c == '|').Count()>10) + { + lblLoad.Text = "Loading: "; + } + + lblLoad.Refresh(); + Application.DoEvents(); + System.Threading.Thread.Sleep(500); + + + + + + } + + ModList = ModList.OrderBy(m => m.ID).ToList(); + txtOutRAW.Clear(); + txtOut.Clear(); + foreach (ModInfo MI in ModList) + { + txtOutRAW.AppendText(MI.ID + "\r\n"); + StringBuilder tOut = new StringBuilder(); + tOut.Append("ModID: " + MI.ID + " "); + tOut.Append("ModName: " + MI.title + " "); + tOut.Append("Workshop URL: " + MI.URL + "\r\n"); + txtOut.AppendText(tOut.ToString()); + } + lblLoad.Text = "File Loaded"; + + //old code deprecated + /* while (modListIt.MoveNext()) { StringBuilder outputStr = new StringBuilder(); @@ -66,7 +162,7 @@ private void button1_Click(object sender, EventArgs e) } - + */ @@ -75,10 +171,14 @@ private void button1_Click(object sender, EventArgs e) } + + else { txtOutRAW.Text = "Unable To Read File"; } + + } catch (Exception) { - + txtOutRAW.Text = "An Unknown Error Has Occurred"; } @@ -89,5 +189,43 @@ private void txtOut_LinkClicked(Object sender, LinkClickedEventArgs e) Process.Start(e.LinkText); } + private void btnSName_Click(object sender, EventArgs e) + { + ModList = ModList.OrderBy(m => m.title).ToList(); + + txtOutRAW.Clear(); + txtOut.Clear(); + foreach (ModInfo MI in ModList) + { + txtOutRAW.AppendText(MI.ID + "\r\n"); + StringBuilder tOut = new StringBuilder(); + tOut.Append("ModName: " + MI.title + " "); + tOut.Append("ModID: " + MI.ID + " "); + tOut.Append("Workshop URL: " + MI.URL + "\r\n"); + txtOut.AppendText(tOut.ToString()); + } + } + + private void btnSID_Click(object sender, EventArgs e) + { + ModList = ModList.OrderBy(m => m.ID).ToList(); + + txtOutRAW.Clear(); + txtOut.Clear(); + foreach (ModInfo MI in ModList) + { + txtOutRAW.AppendText(MI.ID + "\r\n"); + StringBuilder tOut = new StringBuilder(); + tOut.Append("ModID: " + MI.ID + " "); + tOut.Append("ModName: " + MI.title + " "); + tOut.Append("Workshop URL: " + MI.URL + "\r\n"); + txtOut.AppendText(tOut.ToString()); + } + } + + + + + } } diff --git a/SBoxModList/SBoxModList.csproj b/SBoxModList/SBoxModList.csproj index f8da77e..4c7b615 100644 --- a/SBoxModList/SBoxModList.csproj +++ b/SBoxModList/SBoxModList.csproj @@ -60,7 +60,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Form1.cs"> - <SubType>Form</SubType> + <SubType>Component</SubType> </Compile> <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> @@ -79,6 +79,7 @@ <AutoGen>True</AutoGen> <DependentUpon>Resources.resx</DependentUpon> </Compile> + <None Include="ClassDiagram1.cd" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> diff --git a/SBoxModList/bin/Release/SBoxModList-1.0.zip b/SBoxModList/bin/Release/SBoxModList-1.0.zip new file mode 100644 index 0000000..e48ff89 Binary files /dev/null and b/SBoxModList/bin/Release/SBoxModList-1.0.zip differ diff --git a/SBoxModList/bin/Release/SBoxModList.exe b/SBoxModList/bin/Release/SBoxModList.exe index ceee49f..4e9d5b1 100644 Binary files a/SBoxModList/bin/Release/SBoxModList.exe and b/SBoxModList/bin/Release/SBoxModList.exe differ diff --git a/SBoxModList/bin/Release/SBoxModList.pdb b/SBoxModList/bin/Release/SBoxModList.pdb index 96b92a0..b097ca8 100644 Binary files a/SBoxModList/bin/Release/SBoxModList.pdb and b/SBoxModList/bin/Release/SBoxModList.pdb differ diff --git a/SBoxModList/bin/Release/SBoxModList.vshost.zip b/SBoxModList/bin/Release/SBoxModList.vshost.zip new file mode 100644 index 0000000..53682fe Binary files /dev/null and b/SBoxModList/bin/Release/SBoxModList.vshost.zip differ diff --git a/SBoxModList/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/SBoxModList/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache index 2b844a7..270dd06 100644 Binary files a/SBoxModList/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/SBoxModList/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/SBoxModList/obj/x86/Release/SBoxModList.Form1.resources b/SBoxModList/obj/x86/Release/SBoxModList.WebTimeout.resources similarity index 100% rename from SBoxModList/obj/x86/Release/SBoxModList.Form1.resources rename to SBoxModList/obj/x86/Release/SBoxModList.WebTimeout.resources diff --git a/SBoxModList/obj/x86/Release/SBoxModList.csproj.FileListAbsolute.txt b/SBoxModList/obj/x86/Release/SBoxModList.csproj.FileListAbsolute.txt index 74a4205..68937fb 100644 --- a/SBoxModList/obj/x86/Release/SBoxModList.csproj.FileListAbsolute.txt +++ b/SBoxModList/obj/x86/Release/SBoxModList.csproj.FileListAbsolute.txt @@ -1,8 +1,7 @@ D:\Software Projects\SBoxModList\SBoxModList\bin\Release\SBoxModList.exe D:\Software Projects\SBoxModList\SBoxModList\bin\Release\SBoxModList.pdb -D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.Form1.resources +D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.WebTimeout.resources D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.Properties.Resources.resources D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.csproj.GenerateResource.Cache D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.exe D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.pdb -D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.csprojResolveAssemblyReference.cache diff --git a/SBoxModList/obj/x86/Release/SBoxModList.csproj.GenerateResource.Cache b/SBoxModList/obj/x86/Release/SBoxModList.csproj.GenerateResource.Cache index d14de29..e6e99ac 100644 Binary files a/SBoxModList/obj/x86/Release/SBoxModList.csproj.GenerateResource.Cache and b/SBoxModList/obj/x86/Release/SBoxModList.csproj.GenerateResource.Cache differ diff --git a/SBoxModList/obj/x86/Release/SBoxModList.csprojResolveAssemblyReference.cache b/SBoxModList/obj/x86/Release/SBoxModList.csprojResolveAssemblyReference.cache deleted file mode 100644 index 9d7baed..0000000 Binary files a/SBoxModList/obj/x86/Release/SBoxModList.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/SBoxModList/obj/x86/Release/SBoxModList.exe b/SBoxModList/obj/x86/Release/SBoxModList.exe index ceee49f..4e9d5b1 100644 Binary files a/SBoxModList/obj/x86/Release/SBoxModList.exe and b/SBoxModList/obj/x86/Release/SBoxModList.exe differ diff --git a/SBoxModList/obj/x86/Release/SBoxModList.pdb b/SBoxModList/obj/x86/Release/SBoxModList.pdb index 96b92a0..b097ca8 100644 Binary files a/SBoxModList/obj/x86/Release/SBoxModList.pdb and b/SBoxModList/obj/x86/Release/SBoxModList.pdb differ diff --git a/ScreenShot.PNG b/ScreenShot.PNG index 47ed129..3227057 100644 Binary files a/ScreenShot.PNG and b/ScreenShot.PNG differ