From: <jmb...@us...> - 2013-07-10 20:51:16
|
Revision: 4602 http://sourceforge.net/p/mp-plugins/code/4602 Author: jmbillings Date: 2013-07-10 20:51:10 +0000 (Wed, 10 Jul 2013) Log Message: ----------- Add code to get Description and initial skin mods Modified Paths: -------------- trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs trunk/plugins/APODPlugin/APODPlugin/APODPlugin.xml trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.dll trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.pdb trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.xml trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.dll trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb Modified: trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs =================================================================== --- trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-07-09 08:19:38 UTC (rev 4601) +++ trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-07-10 20:51:10 UTC (rev 4602) @@ -23,6 +23,7 @@ List<String> apodURLs; int currentStep = 0; directions direction; + string information; internal APODDownloader() { @@ -77,6 +78,13 @@ if (!apodURLs.Contains(prevURL)) apodURLs.Add(prevURL); + //Look for information + Match infoMatcher = Regex.Match(pagesource, "(?<=<b> Explanation: </b>)(.+?)(?=<p> <center>)", RegexOptions.Singleline); + if (infoMatcher.Success) + information = StripTagsCharArray(infoMatcher.Value).Replace("\n"," "); + else + information = "No information found!"; + //Now look for image Match sourceMatcher = Regex.Match(pagesource, "(?<=<IMG SRC=\")(.+?)(?=\")", RegexOptions.Singleline); if (sourceMatcher.Success) @@ -118,9 +126,37 @@ resultStream.Dispose(); imageClient.Dispose(); - onDownloadComplete(this, new downloadCompleteEventArgs(bitmap)); + onDownloadComplete(this, new downloadCompleteEventArgs(bitmap, information)); } } + + public static string StripTagsCharArray(string source) + { + char[] array = new char[source.Length]; + int arrayIndex = 0; + bool inside = false; + + for (int i = 0; i < source.Length; i++) + { + char let = source[i]; + if (let == '<') + { + inside = true; + continue; + } + if (let == '>') + { + inside = false; + continue; + } + if (!inside) + { + array[arrayIndex] = let; + arrayIndex++; + } + } + return new string(array, 0, arrayIndex); + } } internal class downloadErrorEventArgs : EventArgs @@ -135,9 +171,11 @@ internal class downloadCompleteEventArgs : EventArgs { internal Image bitmap; - internal downloadCompleteEventArgs(Image b) + internal string infostring; + internal downloadCompleteEventArgs(Image b, string info) { bitmap = b; + infostring = info; } } Modified: trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs =================================================================== --- trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-07-09 08:19:38 UTC (rev 4601) +++ trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-07-10 20:51:10 UTC (rev 4602) @@ -14,6 +14,8 @@ { [SkinControlAttribute(4)] protected GUIImage image = null; + [SkinControlAttribute(5)] + protected GUITextScrollUpControl info = null; int imageStep = 0; APODDownloader downloader; bool downloading = true; @@ -195,6 +197,10 @@ void downloader_onDownloadComplete(object sender, downloadCompleteEventArgs e) { + //set infotext + info.Label = e.infostring; + + //size and set image Rectangle screenRect = Screen.PrimaryScreen.Bounds; Bitmap resizedBitmap = new Bitmap(screenRect.Width, screenRect.Height); Bitmap originalBitmap = (Bitmap)e.bitmap; Modified: trunk/plugins/APODPlugin/APODPlugin/APODPlugin.xml =================================================================== --- trunk/plugins/APODPlugin/APODPlugin/APODPlugin.xml 2013-07-09 08:19:38 UTC (rev 4601) +++ trunk/plugins/APODPlugin/APODPlugin/APODPlugin.xml 2013-07-10 20:51:10 UTC (rev 4602) @@ -11,6 +11,22 @@ <posX>0</posX> <posY>0</posY> </control> + + <control> + <description>info</description> + <type>textboxscrollup</type> + <id>5</id> + <posX>48</posX> + <posY>48</posY> + <width>1824</width> + <height>256</height> + <font>font13</font> + <textcolor>ffffffff</textcolor> + <colordiffuse>ffffffff</colordiffuse> + <seperator>--------------------------------</seperator> + <scrollStartDelaySec>3</scrollStartDelaySec> + <spaceBetweenItems>4</spaceBetweenItems> + </control> </controls> </window> \ No newline at end of file Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.dll =================================================================== (Binary files differ) Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.pdb =================================================================== (Binary files differ) Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.xml =================================================================== --- trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.xml 2013-07-09 08:19:38 UTC (rev 4601) +++ trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.xml 2013-07-10 20:51:10 UTC (rev 4602) @@ -11,6 +11,22 @@ <posX>0</posX> <posY>0</posY> </control> + + <control> + <description>info</description> + <type>textboxscrollup</type> + <id>5</id> + <posX>48</posX> + <posY>48</posY> + <width>1824</width> + <height>256</height> + <font>font13</font> + <textcolor>ffffffff</textcolor> + <colordiffuse>ffffffff</colordiffuse> + <seperator>--------------------------------</seperator> + <scrollStartDelaySec>3</scrollStartDelaySec> + <spaceBetweenItems>4</spaceBetweenItems> + </control> </controls> </window> \ No newline at end of file Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.dll =================================================================== (Binary files differ) Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |