|
From: <jmb...@us...> - 2013-03-20 11:01:19
|
Revision: 4549
http://sourceforge.net/p/mp-plugins/code/4549
Author: jmbillings
Date: 2013-03-20 11:01:17 +0000 (Wed, 20 Mar 2013)
Log Message:
-----------
Changes to allow viewing previous pictures.
Modified Paths:
--------------
trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs
trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs
trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.dll
trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.pdb
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.dll
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb
trunk/plugins/APODPlugin/APODPlugin.v11.suo
trunk/plugins/APODPlugin/MPE/APODPlugin.mpe1
trunk/plugins/APODPlugin/MPE/APODPlugin.xmp2
trunk/plugins/APODPlugin/MPE/update.xml
Modified: trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-03-19 11:07:49 UTC (rev 4548)
+++ trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-03-20 11:01:17 UTC (rev 4549)
@@ -18,17 +18,21 @@
public delegate void downloadCompleteEvent(object sender, downloadCompleteEventArgs e);
WebClient client;
WebClient imageClient;
+ List<String> apodURLs;
+ int currentStep = 0;
internal APODDownloader()
{
client = new WebClient();
- GetImage();
+ apodURLs = new List<string>();
+ apodURLs.Add(APODURL);
}
- internal void GetImage()
+ internal void GetImage(int step)
{
+ currentStep = step;
client.OpenReadCompleted += new OpenReadCompletedEventHandler(readComplete);
- client.OpenReadAsync(new Uri(APODURL));
+ client.OpenReadAsync(new Uri(apodURLs[step]));
}
private void readComplete(object sender, OpenReadCompletedEventArgs args)
@@ -41,6 +45,7 @@
{
try
{
+ String imageURL = "";
Stream resultStream = args.Result;
if (!resultStream.CanRead)
return;
@@ -57,13 +62,19 @@
Match sourceMatcher = Regex.Match(pagesource, "(?<=<IMG SRC=\")(.+?)(?=\")", RegexOptions.Singleline);
if (sourceMatcher.Success)
{
- String imageURL = "http://apod.nasa.gov/apod/" + sourceMatcher.Value;
+ imageURL = "http://apod.nasa.gov/apod/" + sourceMatcher.Value;
downloadImage(imageURL);
}
else
{
onDownloadError(this, new downloadErrorEventArgs(new Exception("Couldn't find image source :(")));
}
+
+ //Find the previous page URL as well... i.e. <a href="ap130319.html"><</a>
+ Match prevMatcher = Regex.Match(pagesource, "(?<=<a href=\")(.+?)(?=\"><</a>)");
+ String prevURL = "http://apod.nasa.gov/apod/" + prevMatcher.Value;
+ if (!apodURLs.Contains(prevURL))
+ apodURLs.Add(prevURL);
}
catch (Exception ex)
{
Modified: trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-03-19 11:07:49 UTC (rev 4548)
+++ trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-03-20 11:01:17 UTC (rev 4549)
@@ -14,7 +14,10 @@
{
[SkinControlAttribute(4)]
protected GUIImage image = null;
-
+ int imageStep = 0;
+ APODDownloader downloader;
+ bool downloading = true;
+
public APODPlugin()
{
}
@@ -113,24 +116,43 @@
protected override void OnPageLoad()
{
GUIWaitCursor.Show();
- APODDownloader downloader = new APODDownloader();
+ downloader = new APODDownloader();
downloader.onDownloadError += downloader_onDownloadError;
downloader.onDownloadComplete += downloader_onDownloadComplete;
- downloader.GetImage();
+ downloader.GetImage(imageStep);
}
public override void OnAction(MediaPortal.GUI.Library.Action action)
{
base.OnAction(action);
+ if (downloading) return;
+
if (action.m_key.KeyCode == 37)
{
//User pressed Left
-
+ GUIWaitCursor.Show();
+ downloading = true;
+ imageStep = imageStep + 1;
+ downloader.GetImage(imageStep);
}
else if (action.m_key.KeyCode == 39)
{
//User pressed right
-
+ if (imageStep == 0)
+ {
+ GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
+ if (dlgOK != null)
+ {
+ dlgOK.SetHeading("Info");
+ dlgOK.SetLine(1, "This is the most recent image!");
+ dlgOK.DoModal(this.GetWindowId());
+ }
+ return;
+ }
+ GUIWaitCursor.Show();
+ downloading = true;
+ imageStep = imageStep - 1;
+ downloader.GetImage(imageStep);
}
else if (action.m_key.KeyCode == 120)
{
@@ -158,10 +180,10 @@
graph.FillRectangle(brush, new RectangleF(0, 0, screenRect.Width, screenRect.Height));
graph.DrawImage(originalBitmap, new Rectangle(((int)screenRect.Width - scaleWidth) / 2, ((int)screenRect.Height - scaleHeight) / 2, scaleWidth, scaleHeight));
- resizedBitmap.Save(System.IO.Path.GetTempPath() + "\\apod.jpg");
- image.SetFileName(System.IO.Path.GetTempPath() + "\\apod.jpg");
+ resizedBitmap.Save(System.IO.Path.GetTempPath() + "\\apod" + imageStep.ToString() + ".jpg");
+ image.SetFileName(System.IO.Path.GetTempPath() + "\\apod" + imageStep.ToString() + ".jpg");
image.Refresh();
-
+ downloading = false;
GUIWaitCursor.Hide();
}
@@ -178,4 +200,4 @@
}
}
}
-}
+}
\ 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/obj/Debug/APODPlugin.dll
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin.v11.suo
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/MPE/APODPlugin.mpe1
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/MPE/APODPlugin.xmp2
===================================================================
--- trunk/plugins/APODPlugin/MPE/APODPlugin.xmp2 2013-03-19 11:07:49 UTC (rev 4548)
+++ trunk/plugins/APODPlugin/MPE/APODPlugin.xmp2 2013-03-20 11:01:17 UTC (rev 4549)
@@ -201,9 +201,9 @@
<Major>1</Major>
<Minor>0</Minor>
<Build>0</Build>
- <Revision>0</Revision>
+ <Revision>1</Revision>
</Version>
- <ExtensionDescription>Display the current APOD (Astronomy Picture of the Day) in Mediaportal</ExtensionDescription>
+ <ExtensionDescription>Display APOD (Astronomy Picture of the Day) pictures in Mediaportal</ExtensionDescription>
<VersionDescription />
<DevelopmentStatus>Rc</DevelopmentStatus>
<OnlineLocation>http://www.team-mediaportal.com/index.php?option=com_mtree&task=att_download&link_id=270&cf_id=24</OnlineLocation>
@@ -262,7 +262,7 @@
<Param1 />
<UpdateOption>OverwriteIfOlder</UpdateOption>
<LocalFileName>M42-130202.jpg</LocalFileName>
- <ZipFileName>Installer{CopyFile}\{46d26bb9-9853-400e-bb4d-ca3ad5017c7e}-M42-130202.jpg</ZipFileName>
+ <ZipFileName>Installer{CopyFile}\{99c5a998-73b1-4821-9009-58eb172a777e}-M42-130202.jpg</ZipFileName>
<DestinationFilename />
</FileItem>
</Items>
Modified: trunk/plugins/APODPlugin/MPE/update.xml
===================================================================
--- trunk/plugins/APODPlugin/MPE/update.xml 2013-03-19 11:07:49 UTC (rev 4548)
+++ trunk/plugins/APODPlugin/MPE/update.xml 2013-03-20 11:01:17 UTC (rev 4549)
@@ -74,7 +74,7 @@
<Build>0</Build>
<Revision>0</Revision>
</Version>
- <ExtensionDescription>Display the current APOD (Astronomy Picture of the Day) in Mediaportal</ExtensionDescription>
+ <ExtensionDescription>Display APOD (Astronomy Picture of the Day) pictures in Mediaportal</ExtensionDescription>
<VersionDescription />
<DevelopmentStatus>Rc</DevelopmentStatus>
<OnlineLocation>http://www.team-mediaportal.com/index.php?option=com_mtree&task=att_download&link_id=270&cf_id=24</OnlineLocation>
@@ -116,5 +116,120 @@
</ProjectSettings>
<IsSkin>false</IsSkin>
</PackageClass>
+ <PackageClass>
+ <Version>2.0</Version>
+ <Groups>
+ <Items>
+ <GroupItem Name="Default">
+ <DisplayName>Default</DisplayName>
+ <DefaulChecked>true</DefaulChecked>
+ <Description>Default</Description>
+ <Files>
+ <Items />
+ </Files>
+ </GroupItem>
+ </Items>
+ </Groups>
+ <Sections>
+ <Items />
+ </Sections>
+ <Dependencies>
+ <Items>
+ <DependencyItem>
+ <Type>MediaPortal</Type>
+ <Id />
+ <MinVersion>
+ <Major>1</Major>
+ <Minor>1</Minor>
+ <Build>6</Build>
+ <Revision>27644</Revision>
+ </MinVersion>
+ <MaxVersion>
+ <Major>1</Major>
+ <Minor>1</Minor>
+ <Build>6</Build>
+ <Revision>27644</Revision>
+ </MaxVersion>
+ <WarnOnly>false</WarnOnly>
+ <Message>requires MediaPortal version 1.1.6.27644 to 1.1.6.27644.</Message>
+ <Name>MediaPortal</Name>
+ </DependencyItem>
+ </Items>
+ </Dependencies>
+ <PluginDependencies>
+ <Items>
+ <PluginDependencyItem AssemblyName="APODPlugin.dll">
+ <CompatibleVersion>
+ <Items>
+ <CompatibleVersionItem>
+ <MinRequiredVersion>1.2.300.0</MinRequiredVersion>
+ <DesignedForVersion>1.2.300.0</DesignedForVersion>
+ </CompatibleVersionItem>
+ </Items>
+ </CompatibleVersion>
+ <SubSystemsUsed>
+ <Items>
+ <SubSystemItem Name="MP.Config" />
+ <SubSystemItem Name="MP.SkinEngine" />
+ </Items>
+ </SubSystemsUsed>
+ </PluginDependencyItem>
+ </Items>
+ </PluginDependencies>
+ <GeneralInfo>
+ <Name>APODPlugin</Name>
+ <Id>7d9c01e5-0408-4f1b-ba3a-e8afd66c22ab</Id>
+ <Author>jmbillings</Author>
+ <HomePage>http://www.team-mediaportal.com/extensions/other/apod-plugin</HomePage>
+ <ForumPage />
+ <UpdateUrl>http://www.team-mediaportal.com/index.php?option=com_mtree&task=att_download&link_id=270&cf_id=52</UpdateUrl>
+ <Version>
+ <Major>1</Major>
+ <Minor>0</Minor>
+ <Build>0</Build>
+ <Revision>1</Revision>
+ </Version>
+ <ExtensionDescription>Display APOD (Astronomy Picture of the Day) pictures in Mediaportal</ExtensionDescription>
+ <VersionDescription />
+ <DevelopmentStatus>Rc</DevelopmentStatus>
+ <OnlineLocation>http://www.team-mediaportal.com/index.php?option=com_mtree&task=att_download&link_id=270&cf_id=24</OnlineLocation>
+ <ReleaseDate>2013-03-17T12:36:33.840161+00:00</ReleaseDate>
+ <Tags />
+ <Location>C:\Users\jamesb\Documents\Visual Studio 2012\Projects\APODPlugin\MPE\APODPlugin.mpe1</Location>
+ <Params>
+ <Items>
+ <SectionParam Name="Online Icon">
+ <Value>http://www.team-mediaportal.com/components/com_mtree/img/listings/s/1882.jpg</Value>
+ <ValueType>String</ValueType>
+ <Description>The icon file of the package stored online (jpg,png,bmp)</Description>
+ </SectionParam>
+ <SectionParam Name="Configuration file">
+ <Value />
+ <ValueType>Template</ValueType>
+ <Description>The file used to configure the extension.
+ If it has .exe extension the will be executed.
+ If it has .dll extension it's started like MP plugin configuration.</Description>
+ </SectionParam>
+ <SectionParam Name="Online Screenshots">
+ <Value />
+ <ValueType>String</ValueType>
+ <Description>Online stored screenshot urls separated by ; </Description>
+ </SectionParam>
+ <SectionParam Name="Force to uninstall on update">
+ <Value>yes</Value>
+ <ValueType>Bool</ValueType>
+ <Description>Show dialog and force to uninstall previous version when updating an extension. Should only be disabled if you are using an NSIS/MSI installer.</Description>
+ </SectionParam>
+ </Items>
+ </Params>
+ </GeneralInfo>
+ <UniqueFileList>
+ <Items />
+ </UniqueFileList>
+ <ProjectSettings>
+ <FolderGroups />
+ </ProjectSettings>
+ <IsSkin>false</IsSkin>
+ </PackageClass>
</Items>
</ExtensionCollection>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|