|
From: <gre...@us...> - 2007-05-07 02:00:12
|
Revision: 383
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=383&view=rev
Author: gregmac45
Date: 2007-05-06 19:00:09 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Fixed GUI,
AddFixed GUI,
Added Settings,
Added Flickr photo sets,
Fixed various Bugs
Modified Paths:
--------------
trunk/plugins/OnlinePhotos/Flickr.cs
trunk/plugins/OnlinePhotos/MyClass.cs
trunk/plugins/OnlinePhotos/myonlinephotos.xml
Modified: trunk/plugins/OnlinePhotos/Flickr.cs
===================================================================
--- trunk/plugins/OnlinePhotos/Flickr.cs 2007-05-06 18:24:35 UTC (rev 382)
+++ trunk/plugins/OnlinePhotos/Flickr.cs 2007-05-07 02:00:09 UTC (rev 383)
@@ -145,6 +145,9 @@
private static List<MyPhoto> loadMyPhotoList(Photo[] photoArray)
{
Photos photos = new Photos();
+ if (photoArray == null)
+ return new List<MyPhoto>();
+
foreach(Photo photo in photoArray)
{
photos.PhotoCollection.Add(photo);
Modified: trunk/plugins/OnlinePhotos/MyClass.cs
===================================================================
--- trunk/plugins/OnlinePhotos/MyClass.cs 2007-05-06 18:24:35 UTC (rev 382)
+++ trunk/plugins/OnlinePhotos/MyClass.cs 2007-05-07 02:00:09 UTC (rev 383)
@@ -13,6 +13,7 @@
using MediaPortal.GUI.Library;
using MediaPortal.Dialogs;
using MediaPortal.GUI.Pictures;
+using MediaPortal.Configuration;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Xml;
@@ -25,73 +26,80 @@
namespace OnlinePhotos
{
- public class MyPhoto
- {
- private String title;
- public String Title
- {
- get
- {
- return title;
- }
- set
- {
- title = value;
-
- }
- }
-
- public String id;
- public String thumbnailUrl;
- public String largeUrl;
- public String mediumUrl;
- public String smallUrl;
- private String thumbName;
- public String ThumbName{
- get{
- if(String.IsNullOrEmpty(thumbName)){
- thumbName = Utils.GetFilename(Utils.GetThumb(title))+id;
- }
- return thumbName;
- }
- }
- }
- public class MyAlbum
- {
- public string id;
- private string title;
- public string coverThumbnailUrl;
- private String thumbName;
- public List<MyPhoto> photoCollection = new List<MyPhoto>();
- public String Title
- {
- get
- {
- return title;
- }
- set
- {
- title = value;
- //ThumbName = "alb"+Utils.GetFilename(Utils.GetThumb(value));
- }
- }
- public String ThumbName{
- get{
- if(String.IsNullOrEmpty(thumbName)){
- thumbName = Utils.GetFilename(Utils.GetThumb(title))+id;
- }
- return thumbName;
- }
- }
- }
+ public class MyPhoto
+ {
+ private String title;
+ public String Title
+ {
+ get
+ {
+ return title;
+ }
+ set
+ {
+ title = value;
- /// <summary>
- /// Description of MyClass.
- /// </summary>
- public class MyOnlinePhotos : GUIWindow, ISetupForm
- {
- [SkinControlAttribute(2)]
- protected GUIButtonControl btnViewAs = null;
+ }
+ }
+
+ public String id;
+ public String thumbnailUrl;
+ public String largeUrl;
+ public String mediumUrl;
+ public String smallUrl;
+ private String thumbName;
+ public String ThumbName
+ {
+ get
+ {
+ if (String.IsNullOrEmpty(thumbName))
+ {
+ thumbName = Utils.GetFilename(Utils.GetThumb(title)) + id;
+ }
+ return thumbName;
+ }
+ }
+ }
+ public class MyAlbum
+ {
+ public string id;
+ private string title;
+ public string coverThumbnailUrl;
+ private String thumbName;
+ public List<MyPhoto> photoCollection = new List<MyPhoto>();
+ public String Title
+ {
+ get
+ {
+ return title;
+ }
+ set
+ {
+ title = value;
+ //ThumbName = "alb"+Utils.GetFilename(Utils.GetThumb(value));
+ }
+ }
+ public String ThumbName
+ {
+ get
+ {
+ if (String.IsNullOrEmpty(thumbName))
+ {
+ thumbName = Utils.GetFilename(Utils.GetThumb(title)) + id;
+ }
+ return thumbName;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Description of MyClass.
+ /// </summary>
+ public class MyOnlinePhotos : GUIWindow, ISetupForm
+ {
+
+ [SkinControlAttribute(2)]
+ protected GUIButtonControl btnViewAs = null;
[SkinControlAttribute(3)]
protected GUIButtonControl btnFlickr = null;
[SkinControlAttribute(31)]
@@ -112,698 +120,750 @@
protected GUIButtonControl btnSearchGrp = null;
[SkinControlAttribute(4)]
protected GUIButtonControl btnPicasa = null;
- [SkinControlAttribute(41)]
- protected GUIButtonControl btnPicasaPhotos = null;
- [SkinControlAttribute(5)]
- protected GUIButtonControl btnSlide = null;
+ //[SkinControlAttribute(41)]
+ //protected GUIButtonControl btnPicasaPhotos = null;
+ [SkinControlAttribute(5)]
+ protected GUIButtonControl btnSlide = null;
[SkinControlAttribute(6)]
- protected GUIButtonControl btnClearCache = null;
+ 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;
- protected List<MyAlbum> CurrentAlbumList;
- 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,
- //showpicture=4,
- //slideshow=5
- }
- public enum View
- {
- List = 0,
- Icons = 1,
- LargeIcons = 2,
- FilmStrip = 3
- }
- public string PluginName()
- {
+ [SkinControlAttribute(8)]
+ protected GUIButtonControl btnBack = null;
+ [SkinControlAttribute(50)]
+ protected GUIFacadeControl facadeView = null;
- return "Online Photos";
+ #region Member variables
+ GUISlideShow _SlideShow;
+ private State _CurrentState = State.HOME;
+ protected View currentView = View.LIST;
+ protected View photoView = View.LARGE_ICONS;
+ protected List<MyPhoto> CurrentPhotoList;
+ protected List<MyAlbum> CurrentAlbumList;
+ protected MyAlbum CurrentAlbum;
+ protected string _CurrentFlickrUser = "";
+ protected string _CurrentPicasaUser = "";
+ protected bool _imagesDone = true;
+ protected bool _stopImgDownload = false;
+ protected bool _onSlideShow = false;
+ protected int _SelectedAlbumIdx = -1;
+ protected int _SelectedPhotoIdx = -1;
+ //protected string _imageDirectory = Config.GetSubFolder(Config.Dir.Thumbs, @"OnlinePhotos");
+ protected string _imageDirectory = String.Empty;
+ protected NameValueCollection _photosToDownload;
+ protected NameValueCollection _AlbumCoversToDownload;
+ #endregion
+ #region Enums
+ public enum State
+ {
+ HOME,
+ FLICKR_HOME,
+ FLICKR_SETS,
+ FLICKR_SET_PHOTOS,
+ FLICKR_PHOTOS,
+ //PICASA_HOME,
+ PICASA_ALBUMS,
+ PICASA_PHOTOS
+ }
+ public enum View
+ {
+ LIST =1,
+ ICONS=2,
+ LARGE_ICONS=3,
+ FILM_STRIP=4
+ }
+ #endregion
+ public string PluginName()
+ {
- }
- public string Description()
- {
+ return "Online Photos";
- return "Flickr and Google Photo Plugin";
+ }
+ public string Description()
+ {
- }
- public string Author()
- {
+ return "Flickr and Google Photo Plugin";
- return "GregMac45";
+ }
+ public string Author()
+ {
- }
- public void ShowPlugin()
- {
+ return "GregMac45";
- //MessageBox.Show("Nothing to configure, this is just an example");
+ }
+ public void ShowPlugin()
+ {
- }
- public bool CanEnable()
- {
+ //MessageBox.Show("Nothing to configure, this is just an example");
- return true;
- }
- public int GetWindowId()
- {
+ }
+ public bool CanEnable()
+ {
- return GetID;
+ return true;
+ }
+ public int GetWindowId()
+ {
- }
- public bool DefaultEnabled()
- {
- return true;
- }
- public bool HasSetup()
- {
- return false;
- }
- public override int GetID
- {
- get
- {
- return 5757;
- }
- set
- {
- }
- }
- public override bool Init()
- {
- LoadSettings();
- return Load(GUIGraphicsContext.Skin + @"\myonlinephotos.xml");
+ return GetID;
- }
- public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
- {
- strButtonText = PluginName();
+ }
+ public bool DefaultEnabled()
+ {
+ return true;
+ }
+ public bool HasSetup()
+ {
+ return false;
+ }
+ public override int GetID
+ {
+ get
+ {
+ return 5757;
+ }
+ set
+ {
+ }
+ }
+ public override bool Init()
+ {
+ _imageDirectory = Config.GetSubFolder(Config.Dir.Thumbs, @"OnlinePhotos");
+ if (Directory.Exists(_imageDirectory) == false)
+ {
+ try
+ {
+ Directory.CreateDirectory(_imageDirectory);
+ }
+ catch (Exception)
+ {
+ //Log.Error("Unable to create thumb directory {0}", _imageDirectory);
+ _imageDirectory = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
+ }
+ }
+ _imageDirectory += "/";
+ Log.Info("OnlinePhotos thumb Dir: {0}", _imageDirectory);
+ LoadSettings();
+ return Load(GUIGraphicsContext.Skin + @"\myonlinephotos.xml");
- strButtonImage = String.Empty;
+ }
+ public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
+ {
+ strButtonText = PluginName();
- strButtonImageFocus = String.Empty;
+ strButtonImage = String.Empty;
- strPictureImage = String.Empty;
+ strButtonImageFocus = String.Empty;
- return true;
- }
- public bool ShowDefaultHome()
- {
- return true;
- }
- protected override void OnPageLoad()
- {
- Log.Info("in OnPageLoad");
- if (_CurrentState == State.home)
- {
- //_log.Info("onPageLoad state home");
- GUIPropertyManager.SetProperty("#header.label", "Online Photos");
- DisplayHome();
- //DisplaySites();
- }
- 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)
+ strPictureImage = String.Empty;
+
+ return true;
+ }
+ public bool ShowDefaultHome()
+ {
+ return true;
+ }
+ protected override void OnPageLoad()
+ {
+ Log.Info("in OnPageLoad");
+ base.OnPageLoad();
+ switch (_CurrentState)
{
- Log.Info("OnPageLoad with state ={0} and imageDone = false calling GetImages(_photosToDownload)",_CurrentState);
- if (_CurrentState == State.album_photos || _CurrentState == State.photos)
- {
- getImages(_photosToDownload);
- }
+ case State.HOME:
+ GUIPropertyManager.SetProperty("#header.label", "Online Photos");
+ SetStateHome();
+ break;
+ case State.FLICKR_PHOTOS:
+ GUIPropertyManager.SetProperty("#header.label", "FLICKR");
+ SetStateFlickrPhotos();
+ DisplayCurrentPhotos(!_imagesDone);
+ if (_SelectedPhotoIdx > -1)
+ {
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+ GUIControl.SelectItemControl(GetID, facadeView.GetID, _SelectedPhotoIdx);
+ }
+ break;
+ case State.FLICKR_SET_PHOTOS:
+ GUIPropertyManager.SetProperty("#header.label", "FLICKR");
+ SetStateFlickrSetPhotos();
+ DisplayCurrentPhotos(!_imagesDone);
+ if (_SelectedPhotoIdx > -1)
+ {
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+ GUIControl.SelectItemControl(GetID, facadeView.GetID, _SelectedPhotoIdx);
+ }
+ break;
+ case State.PICASA_PHOTOS:
+ GUIPropertyManager.SetProperty("#header.label", "PICASA");
+ SetStatePicasaPhotos();
+ DisplayCurrentPhotos(!_imagesDone);
+ if (_SelectedPhotoIdx > -1)
+ {
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+ GUIControl.SelectItemControl(GetID, facadeView.GetID, _SelectedPhotoIdx);
+ }
+ break;
}
-
- 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");
+
+ _onSlideShow = false;
+
+
+ }
+ public override bool OnMessage(GUIMessage message)
+ {
+ return base.OnMessage(message);
+ }
+ public override void OnAction(Action action)
+ {
+
+ if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
+ {
+ OnPreviousWindow();
+ return;
+ }
+ base.OnAction(action);
+ }
+ protected override void OnPreviousWindow()
+ {
+ Log.Info("Current state = {0}", _CurrentState);
+ switch (_CurrentState)
+ {
+ case State.FLICKR_PHOTOS:
_stopImgDownload = true;
System.Threading.Thread.Sleep(25);
- DisplayCurrentAlbums();
-
-
- return;
- }
- else if (_CurrentState == State.albums || _CurrentState == State.photos)
- {
- _CurrentState = State.home;
- Log.Info(" P - Sending request to stop img download");
+ GUIControl.ClearControl(GetID, facadeView.GetID);
+ SetStateFlickrHome();
+ //DisplayCurrentAlbums();
+ return;
+ case State.FLICKR_SETS:
_stopImgDownload = true;
System.Threading.Thread.Sleep(25);
- DisplayHome();
-
- return;
- }
-
-
-
- }
- base.OnAction(action);
- }
- protected override void OnPageDestroy(int new_windowId)
- {
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ SetStateFlickrHome();
+ return;
+ case State.FLICKR_SET_PHOTOS:
+ _stopImgDownload = true;
+ System.Threading.Thread.Sleep(25);
+ SetStateFlickrSets();
+ DisplayCurrentAlbums();
+ if (_SelectedAlbumIdx > -1)
+ {
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+ GUIControl.SelectItemControl(GetID, facadeView.GetID, _SelectedAlbumIdx);
+ }
+ return;
+ case State.PICASA_ALBUMS:
+ _stopImgDownload = true;
+ System.Threading.Thread.Sleep(25);
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ SetStateHome();
+ return;
+ case State.FLICKR_HOME:
+ //case State.PICASA_HOME:
+ SetStateHome();
+ return;
- base.OnPageDestroy(new_windowId);
- }
- protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
- {
- if (control == btnViewAs)
- {
- ChangeFacadeView();
- }
- else if (control == btnSlide)
- {
- OnSlideShow();
- }else if(control == btnClearCache){
- ClearCache();
+ case State.PICASA_PHOTOS:
+ _stopImgDownload = true;
+ System.Threading.Thread.Sleep(25);
+ SetStatePicasaAlbums();
+ DisplayCurrentAlbums();
+ if (_SelectedAlbumIdx > -1)
+ {
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+ GUIControl.SelectItemControl(GetID, facadeView.GetID, _SelectedAlbumIdx);
+ }
+ return;
+ default:
+ base.OnPreviousWindow();
+ break;
}
- else if (control == facadeView && _CurrentState == State.home)
- {
- String SelectedSiteId = facadeView.SelectedListItem.Path;
- String userInput = "" ;
- switch (SelectedSiteId)
- {
- case "1":
- DisplayInterestingFlickrPhotos();
- _CurrentState = State.photos;
- break;
- case "2":
- DisplayRecentFlickrPhotos();
- _CurrentState = State.photos;
- break;
- case "3":
-
- if (GetUserInputString(ref userInput))
- {
- DisplayFlickrPhotosWithTags(userInput);
- _CurrentState = State.photos;
-
- }
- break;
- case "4":
- if (GetUserInputString(ref userInput))
- {
- DisplayFlickrPhotosWithText(userInput);
- _CurrentState = State.photos;
+
+ }
+ protected override void OnPageDestroy(int new_windowId)
+ {
+ SaveSettings();
+ base.OnPageDestroy(new_windowId);
+ }
+ protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
+ {
+ String userInput = "";
+ if (control == btnClearCache) ClearCache();
+ else if (control == btnViewAs) ChangeFacadeView();
+ else if (control == btnClearCache) ClearCache();
+ else if (control == btnSettings) OnSettings();
+ else if (control == btnSlide) OnSlideShow();
+ else if (control == facadeView) OnClick();
+ else if (control == btnBack) OnPreviousWindow();
+ else if (control == btnFlickr)
+ {
+ SetStateFlickrHome();
+ }
+ else if (control == btnInterest)
+ {
+ DisplayInterestingFlickrPhotos();
+ SetStateFlickrPhotos();
+ }
+ else if (control == btnRecent)
+ {
+ SetStateFlickrPhotos();
+ DisplayRecentFlickrPhotos();
+
+ }
- }
- break;
- case "5":
- DisplayFlickrUserPhotos("gregmac45");
- _CurrentState = State.photos;
+ else if (control == btnSearchTag)
+ {
+ if (GetUserInputString(ref userInput))
+ {
-
- break;
- case "6":
- if (GetUserInputString(ref userInput))
- {
- DisplayFlickrGroupsWithText(userInput);
- _CurrentState = State.photos;
- }
- break;
- case "7":
- DisplayFlickrUserFavoritePhotos("gregmac45");
- _CurrentState = State.photos;
- break;
- case "8":
- DisplayPicasaAlbums("gregmac45");
- _CurrentState = State.albums;
- break;
- }
- }
- else if (control == facadeView && _CurrentState == State.albums)
- {
- _stopImgDownload = true;
- CurrentAlbum = CurrentAlbumList[facadeView.SelectedListItemIndex];
- DisplayAlbumPhotos();
-
- _CurrentState = State.album_photos;
- }
- else if (control == facadeView && (_CurrentState == State.photos || _CurrentState== State.album_photos))
- {
- OnShowPicture(facadeView.SelectedListItem.Path);
- }
- }
- public void DisplayInterestingFlickrPhotos()
- {
- CurrentPhotoList =
- MyFlickr.getInterestingPhotos();
- DisplayCurrentPhotos();
- }
- public void DisplayRecentFlickrPhotos()
- {
- CurrentPhotoList = MyFlickr.getRecentPhotos();
- DisplayCurrentPhotos();
- }
- public void DisplayFlickrPhotosWithTags(String tags)
- {
- CurrentPhotoList = MyFlickr.getPhotosByTag(tags);
- DisplayCurrentPhotos();
- }
- public void DisplayFlickrPhotosWithText(String text)
- {
- CurrentPhotoList = MyFlickr.getPhotosByText(text);
- DisplayCurrentPhotos();
- }
- public void DisplayFlickrGroupsWithText(String text)
- {
- CurrentAlbumList = MyFlickr.getGroupsByText(text);
- DisplayCurrentAlbums();
- }
- public void DisplayFlickrUserPhotos(String user)
- {
- CurrentPhotoList = MyFlickr.getUserPhotos(user);
- DisplayCurrentPhotos();
- }
- public void DisplayFlickrUserFavoritePhotos(String user)
- {
- CurrentPhotoList = MyFlickr.getUserFavoritePhotos(user);
- DisplayCurrentPhotos();
- }
- public void DisplayPicasaAlbums(String user)
- {
- CurrentAlbumList = MyPicasa.getUserAlbums(user);
- DisplayCurrentAlbums();
- }
- private bool GetUserInputString(ref string sString)
- {
- VirtualKeyboard keyBoard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
- keyBoard.Reset();
- keyBoard.IsSearchKeyboard = true;
- keyBoard.Text = sString;
- keyBoard.DoModal(GetID); // show it...
- if (keyBoard.IsConfirmed) sString = keyBoard.Text;
- return keyBoard.IsConfirmed;
- }
- public void DisplayCurrentPhotos(){
- DisplayCurrentPhotos(true);
- }
- public void DisplayCurrentPhotos(bool refresh)
- {
- facadeView.Clear();
- GUIListItem item;
- int i = 0;
- _photosToDownload = new NameValueCollection();
- foreach (MyPhoto photo in CurrentPhotoList)
- {
- item = new GUIListItem(photo.Title);
- item.Path = photo.mediumUrl;
- item.ItemId = i;
- item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
- if(refresh){
- item.RetrieveArt = false;
- item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
-
-
- _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);
- }
- facadeView.Add(item);
- //GUIWindowManager.Process();
- i++;
+ SetStateFlickrPhotos();
+ DisplayFlickrPhotosWithTags(userInput);
+
- }
- if(refresh){
- getImages(_photosToDownload);
- }
+ }
+ }
+ else if (control == btnSearchTxt)
+ {
+ if (GetUserInputString(ref userInput))
+ {
+ SetStateFlickrPhotos();
+ DisplayFlickrPhotosWithText(userInput);
+
- }
- public void DisplayCurrentAlbums()
- {
- facadeView.Clear();
- GUIListItem item;
- int i = 0;
- _AlbumCoversToDownload = new NameValueCollection();
- foreach (MyAlbum album in CurrentAlbumList)
- {
- item = new GUIListItem(album.Title);
- item.Path = album.id;
- item.ItemId = i;
- //item.IsFolder = true;
- item.RetrieveArt = false;
- item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
- item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
- _AlbumCoversToDownload.Add(album.ThumbName,album.coverThumbnailUrl);
- Log.Info("album thumbnail for {0} is {1}",album.Title,album.coverThumbnailUrl);
- facadeView.Add(item);
- GUIWindowManager.Process();
- i++;
+ }
+ }
+ else if (control == btnFlickrSets)
+ {
+ SetStateFlickrSets();
+ DisplayFlickrUserSets(_CurrentFlickrUser);
+
+ }
+ else if (control == btnFlickrPhotos)
+ {
+ SetStateFlickrPhotos();
+ DisplayFlickrUserPhotos(_CurrentFlickrUser);
+
+ }
- }
- getImages(_AlbumCoversToDownload);
- }
- private void DisplayAlbumPhotos(){
- CurrentPhotoList = MyPicasa.getAlbumPhotos(CurrentAlbum.id);
- DisplayCurrentPhotos();
- }
- /*
- private String GetThumbnail(String lsUrl)
- {
- string lsThumb = MediaPortal.Util.Utils.GetThumb(lsUrl);
- lsThumb = System.IO.Path.GetFileName(lsThumb);
- string lsThumbsDir = "C:\\Temp\\";
- if (System.IO.Directory.Exists(lsThumbsDir) == false)
- {
- System.IO.Directory.CreateDirectory(lsThumbsDir);
- }
- lsThumb = lsThumbsDir + lsThumb;
- //Log.Info(lsThumb);
- if (System.IO.File.Exists(lsThumb) == false)
- {
- String lsFilename = System.IO.Path.GetFileName(lsThumb);
- //moLog.Info("Filename will be {0}", lsFilename);
- MediaPortal.Util.Utils.DownLoadImage(lsUrl, lsThumb);
- }
- if (System.IO.File.Exists(lsThumb))
- {
- //facadeView[liIdx].IconImageBig = lsThumb;
- return lsThumb;
- }
- else
- {
- return "";
- //facadeView[liIdx].IconImageBig = "";
- }
- }
- */
- protected void getImages(NameValueCollection imageList){
+
+ else if (control == btnSearchGrp)
+ {
+ if (GetUserInputString(ref userInput))
+ {
+ SetStateFlickrPhotos();
+ DisplayFlickrGroupsWithText(userInput);
+
+ }
+ }
+ else if (control == btnFlickrFav)
+ {
+ SetStateFlickrPhotos();
+ DisplayFlickrUserFavoritePhotos(_CurrentFlickrUser);
+
+ }
+ else if (control == btnPicasa)
+ {
+ SetStatePicasaAlbums();
+ DisplayPicasaAlbums(_CurrentPicasaUser);
+ }
+ }
+ #region Flickr Api calls
+ public void DisplayInterestingFlickrPhotos()
+ {
+ CurrentPhotoList =
+ MyFlickr.getInterestingPhotos();
+ DisplayCurrentPhotos();
+ }
+ public void DisplayRecentFlickrPhotos()
+ {
+ CurrentPhotoList = MyFlickr.getRecentPhotos();
+ DisplayCurrentPhotos();
+ }
+ public void DisplayFlickrPhotosWithTags(String tags)
+ {
+ CurrentPhotoList = MyFlickr.getPhotosByTag(tags);
+ DisplayCurrentPhotos();
+ }
+ public void DisplayFlickrPhotosWithText(String text)
+ {
+ CurrentPhotoList = MyFlickr.getPhotosByText(text);
+ DisplayCurrentPhotos();
+ }
+ public void DisplayFlickrGroupsWithText(String text)
+ {
+ CurrentAlbumList = MyFlickr.getGroupsByText(text);
+ DisplayCurrentAlbums();
+ }
+ public void DisplayFlickrUserPhotos(String user)
+ {
+ CurrentPhotoList = MyFlickr.getUserPhotos(user);
+ DisplayCurrentPhotos();
+ }
+ public void DisplayFlickrUserSets(String user)
+ {
+ CurrentAlbumList = MyFlickr.getUserPhotoSets(user);
+ DisplayCurrentAlbums();
+ }
+
+ public void DisplayFlickrUserFavoritePhotos(String user)
+ {
+ CurrentPhotoList = MyFlickr.getUserFavoritePhotos(user);
+ DisplayCurrentPhotos();
+ }
+ #endregion
+ public void DisplayPicasaAlbums(String user)
+ {
+ CurrentAlbumList = MyPicasa.getUserAlbums(user);
+ DisplayCurrentAlbums();
+ }
+ private bool GetUserInputString(ref string sString)
+ {
+ VirtualKeyboard keyBoard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
+ keyBoard.Reset();
+ keyBoard.IsSearchKeyboard = true;
+ keyBoard.Text = sString;
+ keyBoard.DoModal(GetID); // show it...
+ if (keyBoard.IsConfirmed) sString = keyBoard.Text;
+ return keyBoard.IsConfirmed;
+ }
+ #region general Display album/photos
+ public void DisplayCurrentPhotos()
+ {
+ DisplayCurrentPhotos(true);
+ }
+ public void DisplayCurrentPhotos(bool refresh)
+ {
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ GUIListItem item;
+ int i = 0;
+ _photosToDownload = new NameValueCollection();
+ foreach (MyPhoto photo in CurrentPhotoList)
+ {
+ item = new GUIListItem(photo.Title);
+
+ item.ItemId = i;
+ item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
+ if (refresh)
+ {
+ item.Path = photo.mediumUrl;
+ item.RetrieveArt = false;
+ item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
+
+
+ _photosToDownload.Add(photo.ThumbName, photo.mediumUrl);
+ //Log.Info("setting photo to url " + photo.mediumUrl);
+ }
+ else
+ {
+ item.Path = _imageDirectory + photo.ThumbName + "L.jpg";
+ item.RetrieveArt = true;
+ item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
+ }
+ facadeView.Add(item);
+ //GUIWindowManager.Process();
+ i++;
+
+ }
+ if (refresh)
+ {
+ getImages(_photosToDownload);
+ }
+
+ }
+ public void DisplayCurrentAlbums()
+ {
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ GUIListItem item;
+ int i = 0;
+ _AlbumCoversToDownload = new NameValueCollection();
+ foreach (MyAlbum album in CurrentAlbumList)
+ {
+ item = new GUIListItem(album.Title);
+ item.Path = album.id;
+ item.ItemId = i;
+ //item.IsFolder = true;
+ item.RetrieveArt = false;
+ item.OnRetrieveArt += new MediaPortal.GUI.Library.GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
+ item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
+ _AlbumCoversToDownload.Add(album.ThumbName, album.coverThumbnailUrl);
+ Log.Info("album thumbnail for {0} is {1}", album.Title, album.coverThumbnailUrl);
+ facadeView.Add(item);
+ GUIWindowManager.Process();
+ i++;
+
+ }
+ getImages(_AlbumCoversToDownload);
+ }
+ private void DisplayAlbumPhotos()
+ {
+ CurrentPhotoList = MyPicasa.getAlbumPhotos(CurrentAlbum.id);
+ DisplayCurrentPhotos();
+ }
+ protected void DisplayFlickrSetPhotos()
+ {
+ CurrentPhotoList = MyFlickr.getPhotoSetPhotos(CurrentAlbum.id);
+ DisplayCurrentPhotos();
+ }
+ #endregion
+ #region image donwload
+ protected void getImages(NameValueCollection imageList)
+ {
Log.Info("Getting images");
BackgroundWorker worker = new BackgroundWorker();
- worker.DoWork += new DoWorkEventHandler(downloadImages);
- worker.RunWorkerAsync(imageList);
+ 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)
- {
+ using (WaitCursor cursor = new WaitCursor())
+ {
+ while (_imagesDone == false)
+ {
+ GUIWindowManager.Process();
+ }
+ }
+ }
+ public void downloadImages(object sender, DoWorkEventArgs e)
+ {
+ //Log.Info("Using thumb directory:{0}", _imageDirectory);
Log.Info("Downloading images");
- _imagesDone = false;
- _stopImgDownload = false;
- //List<String> imageList = (List<String>)e.Argument;
- NameValueCollection imgNameUrlList= (NameValueCollection) e.Argument;
- WebClient client = new WebClient();
-
- 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++;
-
-
- }
- Log.Info("Setting imagesDone to true");
- _imagesDone = true;
- }
- public bool inPhotoState(){
- return _CurrentState == State.album_photos || _CurrentState == State.photos;
- }
- void OnRetrieveCoverArt(GUIListItem item)
- {
- if(inPhotoState() ){
- item.ThumbnailImage = "C:\\Temp\\" + CurrentPhotoList[item.ItemId].ThumbName + ".jpg";
- }else{
- 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.Path;
- }
- private void ChangeFacadeView()
- {
-
-
- switch (currentView)
- {
- case View.List:
- currentView = View.Icons;
- facadeView.View = GUIFacadeControl.ViewMode.SmallIcons;
- break;
- case View.Icons:
- currentView = View.LargeIcons;
- facadeView.View = GUIFacadeControl.ViewMode.LargeIcons;
- break;
- case View.LargeIcons:
- currentView = View.FilmStrip;
- facadeView.View = GUIFacadeControl.ViewMode.Filmstrip;
- break;
- case View.FilmStrip:
- currentView = View.List;
- facadeView.View = GUIFacadeControl.ViewMode.List;
- break;
- }
- GUIControl.FocusControl(GetID, facadeView.GetID);
+ _imagesDone = false;
+ _stopImgDownload = false;
+ //List<String> imageList = (List<String>)e.Argument;
+ NameValueCollection imgNameUrlList = (NameValueCollection)e.Argument;
+ WebClient client = new WebClient();
- string strLine = String.Empty;
- View view = currentView;
- switch (view)
- {
- case View.List:
- strLine = GUILocalizeStrings.Get(101);
- break;
- case View.Icons:
- strLine = GUILocalizeStrings.Get(100);
- break;
- case View.LargeIcons:
- strLine = GUILocalizeStrings.Get(417);
- break;
- case View.FilmStrip:
- strLine = GUILocalizeStrings.Get(733);
- break;
- }
- GUIControl.SetControlLabel(GetID, btnViewAs.GetID, strLine);
+ string imageLocation;
+ string thumbnailLocation;
+ string url;
+ string name;
+ for (int i = 0; i < imgNameUrlList.Count; i++)
+ {
+ url = imgNameUrlList.Get(i);
+ name = imgNameUrlList.GetKey(i);
- }
- private void LoadSettings()
- {
- XmlDocument doc = new XmlDocument();
- try
- {
- doc.Load("OnlinePhotoSettings.xml");
- /*
- XmlNode filter = doc.SelectSingleNode("//settings/filter");
- String lsFilter = filter.InnerText;
- msFilterArray = lsFilter.Split(new char[] { ',' });
- if (msFilterArray.Length == 1 && msFilterArray[0] == "")
+ if (_stopImgDownload)
{
- msFilterArray = null;
+ Log.Info("Received Request to stop Download");
+ break;
}
- XmlNode thumbNode = doc.SelectSingleNode("//settings/thumbLocation");
- msThumbLocation = thumbNode.InnerText;
+ Log.Info("downloading image :" + url);
+
+ imageLocation = _imageDirectory + name + "L.jpg";
+ thumbnailLocation = _imageDirectory + 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++;
- //lsFilterArray
- //Log.Write("filter value {0}",filter.InnerText);
- XmlNode root = doc.SelectSingleNode("//settings/sites/site");
- XmlNodeList nodeList;
- nodeList = root.SelectNodes("//settings/sites/site");
- List<Site> loSiteList = new List<Site>();
- Site loSite;
- XmlNodeList RssNodeList;
- RssLink loRssData;
- bool lbDonwloadDirSet = false;
- foreach (XmlNode chileNode in nodeList)
+ }
+ Log.Info("Setting imagesDone to true");
+ _imagesDone = true;
+ }
+ #endregion
+ protected void OnClick()
+ {
+ Log.Info("processing OnClick() with state={0} and selected index = {1}", _CurrentState, facadeView.SelectedListItemIndex);
+
+ if (_CurrentState == State.PICASA_ALBUMS || _CurrentState == State.FLICKR_SETS)
+ {
+
+ _stopImgDownload = true;
+ CurrentAlbum = CurrentAlbumList[facadeView.SelectedListItemIndex];
+ _SelectedAlbumIdx = facadeView.SelectedListItemIndex;
+ if (_CurrentState == State.FLICKR_SETS)
{
- loSite = new Site();
+ SetStateFlickrSetPhotos();
+ DisplayFlickrSetPhotos();
- XmlNode node = chileNode.SelectSingleNode("name");
- loSite.name = node.InnerText;
+ }
+ else
+ {
+ SetStatePicasaPhotos();
+ DisplayAlbumPhotos();
- node = chileNode.SelectSingleNode("id");
- loSite.id = node.InnerText;
+ }
+ }
+ else if (inPhotoState())
+ {
+ _SelectedPhotoIdx = facadeView.SelectedListItemIndex;
+ OnShowPicture(facadeView.SelectedListItem.Path);
+ }
+ }
+ protected void OnSettings()
+ {
+ GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
+ dlgSel.Reset();
+ if (dlgSel != null)
+ {
+ dlgSel.Add("Cancel");
+ String username = _CurrentFlickrUser;
+ if (String.IsNullOrEmpty(username))
+ {
+ username = "Not Set!";
+ }
- node = chileNode.SelectSingleNode("user");
- if (node != null)
- loSite.username = node.InnerText;
+ dlgSel.Add("Change Flickr username:" + username);
+ username = _CurrentPicasaUser;
+ if (String.IsNullOrEmpty(username))
+ {
+ username = "Not Set!";
+ }
- node = chileNode.SelectSingleNode("password");
- if (node != null)
- loSite.password = node.InnerText;
+ dlgSel.Add("Change Picasa username:" + username);
- node = chileNode.SelectSingleNode("confirmAge");
- if (node != null)
- loSite.confirmAge = node.InnerText == "yes";
- //Console.WriteLine("site Node:{0}", loSite.ToString());
- RssNodeList = chileNode.SelectNodes("rss");
- foreach (XmlNode RssNode in RssNodeList)
+ dlgSel.SetHeading("OnlinePhotos Settings");
+ dlgSel.DoModal(GetID);
+ int liSelectedIdx = dlgSel.SelectedId;
+ if (liSelectedIdx == 2)
+ {
+ GetUserInputString(ref _CurrentFlickrUser);
+ }
+ if (liSelectedIdx == 3)
+ {
+ GetUserInputString(ref _CurrentPicasaUser);
+ if (String.IsNullOrEmpty(_CurrentPicasaUser))
{
- loRssData = new RssLink();
- //node = chileNode.SelectSingleNode("d");
-
- loRssData.name = RssNode.Attributes["name"].InnerText;
- try
- {
- loRssData.isDynamic = RssNode.Attributes["dynamic"].InnerText.Equals("yes");
- Log.Info("Found a dynamic category for site {0}", loSite.name);
- }
- catch (Exception) { }
- loRssData.url = RssNode.InnerText;
- if (lbDonwloadDirSet == false && loSite.id == "99")
- {
- msDownloadDir = loRssData.url;
- lbDonwloadDirSet = true;
- }
- //Console.WriteLine("rss Node:{0}", loRssData.ToString());
- loSite.RssList.Add(loRssData.name, loRssData);
+ btnPicasa.Disabled = true;
}
- moSiteList.Add(loSite.id, loSite);
+ else
+ {
+ btnPicasa.Disabled = false;
+ }
}
- * */
- }
+ }
+ }
+ public bool inPhotoState()
+ {
+ return _CurrentState == State.FLICKR_PHOTOS || _CurrentState == State.PICASA_PHOTOS || _CurrentState == State.FLICKR_SET_PHOTOS;
+ }
+ void OnRetrieveCoverArt(GUIListItem item)
+ {
+ if (inPhotoState())
+ {
+ item.ThumbnailImage = _imageDirectory + CurrentPhotoList[item.ItemId].ThumbName + ".jpg";
+ }
+ else
+ {
+ item.ThumbnailImage = _imageDirectory + 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.Path;
+ }
+ private void ChangeFacadeView()
+ {
- catch (Exception e)
- {
- //moLog.Error(e);
- Log.Error(e);
- }
- }
- private void DisplayHome()
- {
- //facadeView.Clear();
- GUIControl.ClearControl(GetID, facadeView.GetID);
+
+ switch (currentView)
+ {
+ case View.LIST:
+ currentView = View.ICONS;
+ facadeView.View = GUIFacadeControl.ViewMode.SmallIcons;
+ break;
+ case View.ICONS:
+ currentView = View.LARGE_ICONS;
+ facadeView.View = GUIFacadeControl.ViewMode.LargeIcons;
+ break;
+ case View.LARGE_ICONS:
+ currentView = View.FILM_STRIP;
+ facadeView.View = GUIFacadeControl.ViewMode.Filmstrip;
+ break;
+ case View.FILM_STRIP:
+ currentView = View.LIST;
+ facadeView.View = GUIFacadeControl.ViewMode.List;
+ break;
+ }
+ GUIControl.FocusControl(GetID, facadeView.GetID);
+
+ string strLine = String.Empty;
+ View view = currentView;
+ switch (view)
+ {
+ case View.LIST:
+ strLine = GUILocalizeStrings.Get(101);
+ break;
+ case View.ICONS:
+ strLine = GUILocalizeStrings.Get(100);
+ break;
+ case View.LARGE_ICONS:
+ strLine = GUILocalizeStrings.Get(417);
+ break;
+ case View.FILM_STRIP:
+ strLine = GUILocalizeStrings.Get(733);
+ break;
+ }
+ GUIControl.SetControlLabel(GetID, btnViewAs.GetID, strLine);
+ if (_CurrentState != State.HOME && _CurrentState != State.FLICKR_HOME)
+ {
+ photoView = currentView;
+ }
+
+
+ }
+ private void LoadSettings()
+ {
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
+ {
+ _CurrentFlickrUser = xmlreader.GetValueAsString("pictures", "flickr_user", "");
+ _CurrentPicasaUser = xmlreader.GetValueAsString("pictures", "picasa_user", "");
+ photoView = (View)xmlreader.GetValueAsInt("pictures", "onlinephotos_view", (int)View.LIST);
+ }
+ }
+ protected void SaveSettings()
+ {
+ using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
+ {
+ xmlwriter.SetValue("pictures", "onlinephotos_view", (int)photoView);
+ xmlwriter.SetValue("pictures", "picasa_user", _CurrentPicasaUser);
+ xmlwriter.SetValue("pictures", "flickr_user", _CurrentFlickrUser);
+ }
+ }
+ #region state management
+ private void SetStateHome()
+ {
+ _CurrentState = State.HOME;
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ currentView = View.FILM_STRIP;
+ ChangeFacadeView();
hideAllButtons();
btnClearCache.Visible = true;
btnFlickr.Visible = true;
btnPicasa.Visible = true;
+ if (String.IsNullOrEmpty(_CurrentPicasaUser))
+ {
+ btnPicasa.Disabled = true;
+ }
+ else
+ {
+ btnPicasa.Disabled = false;
+ }
btnSettings.Visible = true;
- /*
- GUIListItem loListItem;
- //foreach (Site loSite in moSiteList.Values)
- //{
- loListItem = new GUIListItem("Flickr - Interesting Photos");
- loListItem.Path = "1";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Flickr - Recent Photos");
- loListItem.Path = "2";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
-
- loListItem = new GUIListItem("Flickr - Search by tag");
- loListItem.Path = "3";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Flickr - Search by text");
- loListItem.Path = "4";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Flickr - My Photos");
- loListItem.Path = "5";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Flickr - My Favorites");
- loListItem.Path = "7";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Flickr - Search Groups");
- loListItem.Path = "6";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
-
- loListItem = new GUIListItem("Picasa - My Photos");
- loListItem.Path = "8";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
- */
-
- //}
- //GUIPropertyManager.SetProperty("#itemcount", facadeView.Count-1 + "");
- }
- protected void hideAllButtons() {
+ GUIControl.FocusControl(GetID, btnFlickr.GetID);
+
+ }
+ protected void hideAllButtons()
+ {
btnClearCache.Visible = false;
btnFlickr.Visible = false;
btnFlickrFav.Visible = false;
@@ -811,7 +871,7 @@
btnFlickrSets.Visible = false;
btnInterest.Visible = false;
btnPicasa.Visible = false;
- btnPicasaPhotos.Visible = false;
+ //btnPicasaPhotos.Visible = false;
btnRecent.Visible = false;
btnSearchGrp.Visible = false;
btnSearchTag.Visible = false;
@@ -819,138 +879,209 @@
btnSettings.Visible = false;
btnSlide.Visible = false;
btnViewAs.Visible = false;
+ btnBack.Visible = false;
+ }
+ protected void SetStateFlickrHome()
+ {
+ _CurrentState = State.FLICKR_HOME;
+ hideAllButtons();
+ GUIControl.ClearControl(GetID, facadeView.GetID);;
+ currentView = View.FILM_STRIP;
+ ChangeFacadeView();
+ btnFlickrFav.Visible = true;
+ btnFlickrPhotos.Visible = true;
+ btnFlickrSets.Visible = true;
+ if (String.IsNullOrEmpty(_CurrentFlickrUser))
+ {
+ btnFlickrFav.Disabled = true;
+ btnFlickrPhotos.Disabled = true;
+ btnFlickrSets.Disabled = true;
+ }
+ else
+ {
+ btnFlickrFav.Disabled = false;
+ btnFlickrPhotos.Disabled = false;
+ btnFlickrSets.Disabled = false;
+ }
+ btnInterest.Visible = true;
+ btnRecent.Visible = true;
+ btnSearchGrp.Visible = true;
+ btnSearchTag.Visible = true;
+ btnSearchTxt.Visible = true;
+ btnBack.Visible = true;
+ GUIControl.FocusControl(GetID, btnFlickrPhotos.GetID);
+
}
+ protected void SetStateFlickrSets()
+ {
+ _CurrentState = State.FLICKR_SETS;
+ if (photoView == View.LIST)
+ {
+ currentView = View.FILM_STRIP;
+ }else{
+ currentView = (View)(int)photoView - 1;
+ }
+ ChangeFacadeView();
+ hideAllButtons();
+ btnViewAs.Visible = true;
+ btnSlide.Visible = true;
+ btnBack.Visible = true;
+ this.LooseFocus();
+ GUIControl.FocusControl(GetID, btnBack.GetID);
+ }
+ protected void SetStateFlickrSetPhotos()
+ {
+ _CurrentState = State.FLICKR_SET_PHOTOS;
+ if (photoView == View.LIST)
+ {
+ currentView = View.FILM_STRIP;
+ }else{
+ currentView = (View)(int)photoView - 1;
+ }
+ ChangeFacadeView();
+ hideAllButtons();
+ btnViewAs.Visible = true;
+ btnSlide.Visible = true;
+ btnBack.Visible = true;
+ this.LooseFocus();
+ GUIControl.FocusControl(GetID, btnBack.GetID);
+ }
+ protected void SetStateFlickrPhotos()
+ {
+ _CurrentState = State.FLICKR_PHOTOS;
+ if (photoView == View.LIST)
+ {
+ currentView = View.FILM_STRIP;
+ }else{
+ currentView = (View)(int)photoView - 1;
+ }
+ ChangeFacadeView();
+ hideAllButtons();
+ btnViewAs.Visible = true;
+ btnSlide.Visible = true;
+ btnBack.Visible = true;
+ GUIControl.FocusControl(GetID, btnBack.GetID);
+ }
/*
- private void LoadFlickrCategories()
- {
- GUIControl.ClearControl(GetID, facadeView.GetID);
+ protected void SetStatePicasaHome()
+ {
+ hideAllButtons();
+ btnPicasaPhotos.Visible = true;
+ _CurrentState = State.PICASA_HOME;
+ }
+ * */
+ protected void SetStatePicasaAlbums()
+ {
+ _CurrentState = State.PICASA_ALBUMS;
+ if (photoView == View.LIST)
+ {
+ currentView = View.FILM_STRIP;
+ }else{
+ currentView = (View)(int)photoView - 1;
+ }
+ ChangeFacadeView();
+ hideAllButtons();
+ btnViewAs.Visible = true;
+ btnSlide.Visible = true;
+ btnBack.Visible = true;
+ GUIControl.FocusControl(GetID, btnBack.GetID);
+ }
+ protected void SetStatePicasaPhotos()
+ {
+ _CurrentState = State.PICASA_PHOTOS;
+ if (photoView == View.LIST)
+ {
+ currentView = View.FILM_STRIP;
+ }else{
+ currentView = (View)(int)photoView - 1;
+ }
+ ChangeFacadeView();
+ hideAllButtons();
+ btnViewAs.Visible = true;
+ btnSlide.Visible = true;
+ btnBack.Visible = true;
+ GUIControl.FocusControl(GetID, btnBack.GetID);
+ }
+ #endregion
+ #region slideshow methods
+ void OnSlideShow()
+ {
+ OnSlideShow(0);
+ }
+ void OnSlideShow(int iStartItem)
+ {
+ 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;
- GUIListItem loListItem;
- loListItem = new GUIListItem("..");
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
+ _SlideShow.Reset();
- loListItem = new GUIListItem("Interesting Photos");
- loListItem.Path = "1";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
+ if ((iStartItem < 0) || (iStartItem > CurrentPhotoList.Count))
+ iStartItem = 0;
+ int i = iStartItem;
+ do
+ {
+ GUIListItem item = facadeView[i];
+ if (!item.IsFolder && !item.IsRemote && item.RetrieveArt)
+ {
+ _SlideShow.Add(facadeView[i].Path);
+ }
- loListItem = new GUIListItem("Recent Photos");
- loListItem.Path = "2";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
+ i++;
+ if (i >= CurrentPhotoList.Count)
+ {
+ i = 0;
+ }
+ }
+ while (i != iStartItem);
- loListItem = new GUIListItem("My Photos");
- loListItem.Path = "3";
- loListItem.IsFolder = true;
- MediaPortal.Util.Utils.SetDefaultIcons(loListItem);
- facadeView.Add(loListItem);
+ if (_SlideShow.Count > 0)
+ {
+ //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);
+ }
+ }
+ void OnShowPicture(string strFile)
+ {
+ _SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW);
+ if (_SlideShow == null)
+ return;
- }
- * */
- void OnSlideShow()
- {
- OnSlideShow(0);
- ...
[truncated message content] |