From: <gre...@us...> - 2007-05-05 00:39:14
|
Revision: 377 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=377&view=rev Author: gregmac45 Date: 2007-05-04 17:39:12 -0700 (Fri, 04 May 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/OnlinePhotos/MyClass.cs trunk/plugins/OnlinePhotos/OnlinePhotos.csproj trunk/plugins/OnlinePhotos/OnlinePhotos.suo trunk/plugins/OnlinePhotos/myonlinephotos.xml Modified: trunk/plugins/OnlinePhotos/MyClass.cs =================================================================== --- trunk/plugins/OnlinePhotos/MyClass.cs 2007-05-04 17:23:57 UTC (rev 376) +++ trunk/plugins/OnlinePhotos/MyClass.cs 2007-05-05 00:39:12 UTC (rev 377) @@ -9,14 +9,18 @@ using System; using MediaPortal; using MediaPortal.Util; +using MediaPortal.Utils; using MediaPortal.GUI.Library; using MediaPortal.Dialogs; using MediaPortal.GUI.Pictures; using System.Collections.Generic; +using System.Collections.Specialized; using System.Xml; using System.Net; using System.Web; using System.IO; +using System.Drawing; +using System.Drawing.Imaging; using System.ComponentModel; namespace OnlinePhotos @@ -36,6 +40,7 @@ } } + public String id; public String thumbnailUrl; public String largeUrl; @@ -87,10 +92,37 @@ { [SkinControlAttribute(2)] protected GUIButtonControl btnViewAs = null; - [SkinControlAttribute(3)] + [SkinControlAttribute(3)] + protected GUIButtonControl btnFlickr = null; + [SkinControlAttribute(31)] + protected GUIButtonControl btnFlickrPhotos = null; + [SkinControlAttribute(32)] + protected GUIButtonControl btnFlickrSets = null; + [SkinControlAttribute(33)] + protected GUIButtonControl btnFlickrFav = null; + [SkinControlAttribute(34)] + protected GUIButtonControl btnInterest = null; + [SkinControlAttribute(35)] + protected GUIButtonControl btnRecent = null; + [SkinControlAttribute(36)] + protected GUIButtonControl btnSearchTag = null; + [SkinControlAttribute(37)] + protected GUIButtonControl btnSearchTxt = null; + [SkinControlAttribute(38)] + protected GUIButtonControl btnSearchGrp = null; + [SkinControlAttribute(4)] + protected GUIButtonControl btnPicasa = null; + [SkinControlAttribute(41)] + protected GUIButtonControl btnPicasaPhotos = null; + [SkinControlAttribute(5)] protected GUIButtonControl btnSlide = null; + [SkinControlAttribute(6)] + protected GUIButtonControl btnClearCache = null; + [SkinControlAttribute(7)] + protected GUIButtonControl btnSettings = null; [SkinControlAttribute(50)] protected GUIFacadeControl facadeView = null; + GUISlideShow _SlideShow; private State _CurrentState = State.home; protected View currentView = View.List; protected List<MyPhoto> CurrentPhotoList; @@ -98,12 +130,18 @@ protected MyAlbum CurrentAlbum; protected bool _imagesDone = true; protected bool _stopImgDownload = false; + protected bool _onSlideShow = false; + protected string _imageDirectory = @"C:\Temp\"; + protected NameValueCollection _photosToDownload; + protected NameValueCollection _AlbumCoversToDownload; public enum State { home = 0, albums = 1, photos = 2, - album_photos = 3 + album_photos = 3, + //showpicture=4, + //slideshow=5 } public enum View { @@ -112,75 +150,48 @@ LargeIcons = 2, FilmStrip = 3 } - public string PluginName() { return "Online Photos"; - } - - // Returns the description of the plugin is shown in the plugin menu - + } public string Description() { return "Flickr and Google Photo Plugin"; } - - // Returns the author of the plugin which is shown in the plugin menu - public string Author() { return "GregMac45"; - } - - // show the setup dialog - + } public void ShowPlugin() { //MessageBox.Show("Nothing to configure, this is just an example"); } - - // Indicates whether plugin can be enabled/disabled - public bool CanEnable() { return true; - } - - // get ID of windowplugin belonging to this setup - public int GetWindowId() { return GetID; } - - // Indicates if plugin is enabled by default; - public bool DefaultEnabled() { - return true; - } - - // indicates if a plugin has its own setup screen - public bool HasSetup() { - return false; - } public override int GetID { @@ -192,7 +203,6 @@ { } } - public override bool Init() { LoadSettings(); @@ -217,6 +227,7 @@ } protected override void OnPageLoad() { + Log.Info("in OnPageLoad"); if (_CurrentState == State.home) { //_log.Info("onPageLoad state home"); @@ -224,43 +235,68 @@ DisplayHome(); //DisplaySites(); } - else if (_CurrentState == State.photos) + else if (_CurrentState == State.photos || _CurrentState == State.album_photos) { + Log.Info("OnPageLoad with state ={0} calling DisplayCurrentPhotos with false",_CurrentState); DisplayCurrentPhotos(false); } + currentView = View.Icons; ChangeFacadeView(); + _onSlideShow = false; + if (_imagesDone == false) + { + Log.Info("OnPageLoad with state ={0} and imageDone = false calling GetImages(_photosToDownload)",_CurrentState); + if (_CurrentState == State.album_photos || _CurrentState == State.photos) + { + getImages(_photosToDownload); + } + } - base.OnPageLoad(); } + public override bool OnMessage(GUIMessage message) + { + return base.OnMessage(message); + } public override void OnAction(Action action) { + if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU) { + Log.Info("in Action previous menu"); if (_CurrentState == State.album_photos) { + _CurrentState = State.albums; + Log.Info(" AP - Sending request to stop img download"); + _stopImgDownload = true; + System.Threading.Thread.Sleep(25); DisplayCurrentAlbums(); - _CurrentState = State.albums; + + return; } else if (_CurrentState == State.albums || _CurrentState == State.photos) { + _CurrentState = State.home; + Log.Info(" P - Sending request to stop img download"); + _stopImgDownload = true; + System.Threading.Thread.Sleep(25); DisplayHome(); - _CurrentState = State.home; + return; } - _stopImgDownload = true; + + } base.OnAction(action); - } + } protected override void OnPageDestroy(int new_windowId) { base.OnPageDestroy(new_windowId); - } - + } protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnViewAs) @@ -270,10 +306,13 @@ else if (control == btnSlide) { OnSlideShow(); - } + }else if(control == btnClearCache){ + ClearCache(); + } else if (control == facadeView && _CurrentState == State.home) { String SelectedSiteId = facadeView.SelectedListItem.Path; + String userInput = "" ; switch (SelectedSiteId) { case "1": @@ -285,21 +324,19 @@ _CurrentState = State.photos; break; case "3": - string q = ""; - if (GetUserInputString(ref q)) + + if (GetUserInputString(ref userInput)) { - DisplayFlickrPhotosWithTags(q); + DisplayFlickrPhotosWithTags(userInput); _CurrentState = State.photos; } break; - case "4": - string text = ""; - if (GetUserInputString(ref text)) + case "4": + if (GetUserInputString(ref userInput)) { - - DisplayFlickrPhotosWithText(text); + DisplayFlickrPhotosWithText(userInput); _CurrentState = State.photos; } @@ -310,11 +347,10 @@ break; - case "6": - string gtext = ""; - if (GetUserInputString(ref gtext)) + case "6": + if (GetUserInputString(ref userInput)) { - DisplayFlickrGroupsWithText(gtext); + DisplayFlickrGroupsWithText(userInput); _CurrentState = State.photos; } break; @@ -338,7 +374,7 @@ } else if (control == facadeView && (_CurrentState == State.photos || _CurrentState== State.album_photos)) { - OnShowPicture(facadeView.SelectedListItem.ThumbnailImage); + OnShowPicture(facadeView.SelectedListItem.Path); } } public void DisplayInterestingFlickrPhotos() @@ -400,7 +436,7 @@ facadeView.Clear(); GUIListItem item; int i = 0; - List<String> ImageList = new List<string>(); + _photosToDownload = new NameValueCollection(); foreach (MyPhoto photo in CurrentPhotoList) { item = new GUIListItem(photo.Title); @@ -412,8 +448,8 @@ item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt); - ImageList.Add(photo.mediumUrl); - Log.Info("setting photo to url " + photo.mediumUrl); + _photosToDownload.Add(photo.ThumbName,photo.mediumUrl); + //Log.Info("setting photo to url " + photo.mediumUrl); }else{ item.RetrieveArt = true; item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt); @@ -424,18 +460,7 @@ } if(refresh){ - BackgroundWorker worker = new BackgroundWorker(); - - worker.DoWork += new DoWorkEventHandler(downloadImages); - worker.RunWorkerAsync(ImageList); - - using (WaitCursor cursor = new WaitCursor()) - { - while (_imagesDone == false) - { - GUIWindowManager.Process(); - } - } + getImages(_photosToDownload); } } @@ -444,7 +469,7 @@ facadeView.Clear(); GUIListItem item; int i = 0; - List<String> ImageList = new List<string>(); + _AlbumCoversToDownload = new NameValueCollection(); foreach (MyAlbum album in CurrentAlbumList) { item = new GUIListItem(album.Title); @@ -454,30 +479,20 @@ item.RetrieveArt = false; item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt); item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected); - ImageList.Add(album.coverThumbnailUrl); + _AlbumCoversToDownload.Add(album.ThumbName,album.coverThumbnailUrl); Log.Info("album thumbnail for {0} is {1}",album.Title,album.coverThumbnailUrl); facadeView.Add(item); GUIWindowManager.Process(); i++; } - BackgroundWorker worker = new BackgroundWorker(); - - worker.DoWork += new DoWorkEventHandler(downloadImages); - worker.RunWorkerAsync(ImageList); - - using (WaitCursor cursor = new WaitCursor()) - { - while (_imagesDone == false) - { - GUIWindowManager.Process(); - } - } + getImages(_AlbumCoversToDownload); } private void DisplayAlbumPhotos(){ CurrentPhotoList = MyPicasa.getAlbumPhotos(CurrentAlbum.id); DisplayCurrentPhotos(); } + /* private String GetThumbnail(String lsUrl) { string lsThumb = MediaPortal.Util.Utils.GetThumb(lsUrl); @@ -506,33 +521,73 @@ //facadeView[liIdx].IconImageBig = ""; } } + */ + protected void getImages(NameValueCollection imageList){ + Log.Info("Getting images"); + BackgroundWorker worker = new BackgroundWorker(); + + worker.DoWork += new DoWorkEventHandler(downloadImages); + worker.RunWorkerAsync(imageList); + + using (WaitCursor cursor = new WaitCursor()) + { + while (_imagesDone == false) + { + GUIWindowManager.Process(); + } + } + } public void downloadImages(object sender, DoWorkEventArgs e) { + Log.Info("Downloading images"); _imagesDone = false; _stopImgDownload = false; - List<String> imageList = (List<String>)e.Argument; + //List<String> imageList = (List<String>)e.Argument; + NameValueCollection imgNameUrlList= (NameValueCollection) e.Argument; WebClient client = new WebClient(); - int i=0; - String imageLocation; - foreach (String url in imageList) + + string imageLocation; + string thumbnailLocation; + string url; + string name; + for(int i=0;i<imgNameUrlList.Count;i++) { + url = imgNameUrlList.Get(i); + name = imgNameUrlList.GetKey(i); + if(_stopImgDownload){ + Log.Info("Received Request to stop Download"); break; } + Log.Info("downloading image :"+url); + /* if(inPhotoState() ){ imageLocation = "C:\\Temp\\" + CurrentPhotoList[i].ThumbName + ".jpg"; }else{ imageLocation = "C:\\Temp\\" + CurrentAlbumList[i].ThumbName + ".jpg"; } + */ + imageLocation = "C:\\Temp\\" + name+ "L.jpg"; + thumbnailLocation = "C:\\Temp\\" + name+ ".jpg"; if(System.IO.File.Exists(imageLocation) == false){ client.DownloadFile(url, imageLocation); + if(System.IO.File.Exists(thumbnailLocation) == false){ + //int iRotate = dbs.GetRotation(imageLocation); + MediaPortal.Util.Picture.CreateThumbnail(imageLocation, thumbnailLocation, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0); + System.Threading.Thread.Sleep(25); + } + if(_onSlideShow){ + _SlideShow.Add(imageLocation); + } } + facadeView[i].Path = imageLocation; facadeView[i].RetrieveArt = true; facadeView[i].RefreshCoverArt(); - i++; + //i++; } + Log.Info("Setting imagesDone to true"); _imagesDone = true; } public bool inPhotoState(){ @@ -541,20 +596,18 @@ void OnRetrieveCoverArt(GUIListItem item) { if(inPhotoState() ){ - item.ThumbnailImage = "C:\\Temp\\" + CurrentPhotoList[item.ItemId].ThumbName + ".jpg"; + item.ThumbnailImage = "C:\\Temp\\" + CurrentPhotoList[item.ItemId].ThumbName + ".jpg"; }else{ - item.ThumbnailImage = "C:\\Temp\\" + CurrentAlbumList[item.ItemId].ThumbName + ".jpg"; + item.ThumbnailImage = "C:\\Temp\\" + CurrentAlbumList[item.ItemId].ThumbName + ".jpg"; } } - private void item_OnItemSelected(GUIListItem item, GUIControl parent) { GUIFilmstripControl filmstrip = parent as GUIFilmstripControl; if (filmstrip == null) return; - filmstrip.InfoImageFileName = item.ThumbnailImage; + filmstrip.InfoImageFileName = item.Path; } - private void ChangeFacadeView() { @@ -688,7 +741,12 @@ { //facadeView.Clear(); GUIControl.ClearControl(GetID, facadeView.GetID); - + hideAllButtons(); + btnClearCache.Visible = true; + btnFlickr.Visible = true; + btnPicasa.Visible = true; + btnSettings.Visible = true; + /* GUIListItem loListItem; //foreach (Site loSite in moSiteList.Values) //{ @@ -740,10 +798,30 @@ loListItem.IsFolder = true; MediaPortal.Util.Utils.SetDefaultIcons(loListItem); facadeView.Add(loListItem); - + */ + //} //GUIPropertyManager.SetProperty("#itemcount", facadeView.Count-1 + ""); } + protected void hideAllButtons() { + btnClearCache.Visible = false; + btnFlickr.Visible = false; + btnFlickrFav.Visible = false; + btnFlickrPhotos.Visible = false; + btnFlickrSets.Visible = false; + btnInterest.Visible = false; + btnPicasa.Visible = false; + btnPicasaPhotos.Visible = false; + btnRecent.Visible = false; + btnSearchGrp.Visible = false; + btnSearchTag.Visible = false; + btnSearchTxt.Visible = false; + btnSettings.Visible = false; + btnSlide.Visible = false; + btnViewAs.Visible = false; + + } + /* private void LoadFlickrCategories() { GUIControl.ClearControl(GetID, facadeView.GetID); @@ -774,19 +852,29 @@ } + * */ void OnSlideShow() { OnSlideShow(0); - } - + } void OnSlideShow(int iStartItem) { - - GUISlideShow SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); - if (SlideShow == null) + bool doSlide = true; + if(_imagesDone==false){ + GUIDialogYesNo notify = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); + notify.SetLine(1,"Photos are still downloading."); + notify.SetLine(2,"Select Yes to slide the downloaded photos."); + notify.DoModal(GetID); + doSlide = notify.IsConfirmed; + } + if(doSlide == false){ return; + } + _SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); + if (_SlideShow == null) + return; - SlideShow.Reset(); + _SlideShow.Reset(); if ((iStartItem < 0) || (iStartItem > CurrentPhotoList.Count)) iStartItem = 0; @@ -794,9 +882,9 @@ do { GUIListItem item = facadeView[i]; - if (!item.IsFolder && !item.IsRemote) + if (!item.IsFolder && !item.IsRemote && item.RetrieveArt) { - SlideShow.Add(facadeView[i].ThumbnailImage); + _SlideShow.Add(facadeView[i].Path); } i++; @@ -807,26 +895,45 @@ } while (i != iStartItem); - if (SlideShow.Count > 0) + if (_SlideShow.Count > 0) { - SlideShow.StartSlideShow(); + GUIWindowManager.Callbacks+= new GUIWindowManager.OnCallBackHandler(OnCallBack); + _SlideShow.StartSlideShow(); + _onSlideShow = true; + //GUIWindowManager.Receivers+= new GUIWindowManager.SendMessageHandler(OnSendMessage ); + //Action.ActionType. GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); } } + public void OnCallBack(){ + /* + Log.Info("received call back with onSlideshow set to {0}",_onSlideShow); + if(_imagesDone==false){ + getImages(_photosToDownload); + } + * */ + } void OnShowPicture(string strFile) { - GUISlideShow SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); - if (SlideShow == null) + _SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); + if (_SlideShow == null) return; - SlideShow.Reset(); - SlideShow.Add(strFile); + _SlideShow.Reset(); + _SlideShow.Add(strFile); GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); // SlideShow.Select(strFile); } + protected void ClearCache(){ + String [] strFiles = System.IO.Directory.GetFiles(_imageDirectory,"Thumbs*.jpg"); + foreach(String path in strFiles){ + System.IO.File.Delete(path); + } + + } public void TestSlideShow(String user){ List<MyPhoto> photoList = MyFlickr.getInterestingPhotos(); GUISlideShow SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); Modified: trunk/plugins/OnlinePhotos/OnlinePhotos.csproj =================================================================== --- trunk/plugins/OnlinePhotos/OnlinePhotos.csproj 2007-05-04 17:23:57 UTC (rev 376) +++ trunk/plugins/OnlinePhotos/OnlinePhotos.csproj 2007-05-05 00:39:12 UTC (rev 377) @@ -33,6 +33,9 @@ <PlatformTarget>AnyCPU</PlatformTarget> <FileAlignment>4096</FileAlignment> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <OutputPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Plugins\Windows\</OutputPath> + </PropertyGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <ItemGroup> <Reference Include="Core"> @@ -55,6 +58,8 @@ <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Drawing.Design" /> <Reference Include="System.Xml" /> <Reference Include="Utils"> <HintPath>..\..\MediaPortal\Utils\bin\Release\Utils.DLL</HintPath> Modified: trunk/plugins/OnlinePhotos/OnlinePhotos.suo =================================================================== (Binary files differ) Modified: trunk/plugins/OnlinePhotos/myonlinephotos.xml =================================================================== --- trunk/plugins/OnlinePhotos/myonlinephotos.xml 2007-05-04 17:23:57 UTC (rev 376) +++ trunk/plugins/OnlinePhotos/myonlinephotos.xml 2007-05-05 00:39:12 UTC (rev 377) @@ -25,11 +25,124 @@ </control> <control> <type>button</type> - <description>slideshow button</description> + <description>Flickr</description> <id>3</id> <onright>50</onright> + <label>Flickr</label> + </control> + <control> + <type>button</type> + <description>Picasa</description> + <id>4</id> + <onright>50</onright> + <label>Picasa</label> + </control> + <control> + <type>button</type> + <description>slideshow button</description> + <id>5</id> + <onright>50</onright> <label>Slideshow</label> </control> + <control> + <type>button</type> + <description>cache button</description> + <id>6</id> + <onright>50</onright> + <label>Clear Cache</label> + </control> + <control> + <type>button</type> + <description>cache button</description> + <id>7</id> + <onright>50</onright> + <label>Settings</label> + </control> + </control> + <control> + <description>group element</description> + <type>group</type> + <animation effect="fade" time="250">WindowOpen</animation> + <animation effect="fade" time="500">WindowClose</animation> + <animation effect="slide" time="250" start="-300,0">WindowOpen</animation> + <animation effect="slide" time="500" end="0,-300">WindowClose</animation> + <posX>60</posX> + <posY>97</posY> + <layout>StackLayout</layout> + <control> + <type>button</type> + <description>Flickr</description> + <id>31</id> + <onright>50</onright> + <label>My Photos</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>32</id> + <onright>50</onright> + <label>My Photo Sets</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>33</id> + <onright>50</onright> + <label>My Favorites</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>34</id> + <onright>50</onright> + <label>Interesting Photos</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>35</id> + <onright>50</onright> + <label>Recent Photos</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>36</id> + <onright>50</onright> + <label>Search By Tag</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>37</id> + <onright>50</onright> + <label>Search by Text</label> + </control> + <control> + <type>button</type> + <description>Flickr</description> + <id>38</id> + <onright>50</onright> + <label>Search Groups</label> </control> - </controls> + </control> + <control> + <description>group element</description> + <type>group</type> + <animation effect="fade" time="250">WindowOpen</animation> + <animation effect="fade" time="500">WindowClose</animation> + <animation effect="slide" time="250" start="-300,0">WindowOpen</animation> + <animation effect="slide" time="500" end="0,-300">WindowClose</animation> + <posX>60</posX> + <posY>97</posY> + <layout>StackLayout</layout> + <control> + <type>button</type> + <description>Flickr</description> + <id>41</id> + <onright>50</onright> + <label>My Photos</label> + </control> + </control> + </controls> </window> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |