Accueil  -  RSS  -  Twitter  -  Wiki  -  FAQ  -  Rechercher  -  Vérification messages privés  -  Connexion  -  Enregistrement

Applet Slideshow (Diaporama)

 
Poster un nouveau sujet   Répondre au sujet    SPF Index du Forum -> PointUI dans tous ses états
Voir le sujet précédent :: Voir le sujet suivant  
Auteur Message
Montecristoff
Visiteur en Or


Inscrit le: 30 Oct 2007
Messages: 2975

 #1 MessagePosté le: 12/02/2009 16:02    Sujet du message: Applet Slideshow (Diaporama) Répondre en citant

Sujet ouvert pour accueillir toutes les adaptations ou modifications de l'Applet Slideshow (Diaporama)

...

Cool
_________________
Revenir en haut de page
Voir le profil de l'utilisateur Envoyer un message privé Visiter le site web de l'utilisateur
ManQ1 Nephrite 218DA8
Utilisateur néophyte


Inscrit le: 15 Fév 2009
Messages: 21

 #2 MessagePosté le: 18/02/2009 01:52    Sujet du message: Répondre en citant

Ne pourrait pas t on faire un player MP3 (et AAC aussi pourquoi pas lol) je trouverai cela tres pratique de l avoir sur cet applet...
Revenir en haut de page
Voir le profil de l'utilisateur Envoyer un message privé
ManQ1 Nephrite 218DA8
Utilisateur néophyte


Inscrit le: 15 Fév 2009
Messages: 21

 #3 MessagePosté le: 18/02/2009 03:26    Sujet du message: Répondre en citant

et voici la version FR

//Pointui C Script
/*
COPYRIGHT

Copyright (c) 2008-2009 Pointui Pty Ltd, All Rights Reserved.
ABN: 80 129 073 678

This software is provided under license by Pointui Pty Ltd, and use thereof
is subject to the licensing terms. Distribution of this software is on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND.
This software is protected by Australian and international law.
This software program may not be reproduced, transmitted, or disclosed to
third parties, in whole or in part, in any form or by any manner, electronic
or mechanical, without the express written consent of Pointui Pty Ltd, except
to the extent provided for by applicable license
*/

#region Applet

class SlideshowApplet : Applet
{
//Label lblDebug, lblDebug1;
//int DebugCount;


//data table to store the list of files in the folder being displayed
DataTable tblFiles;

//timer that is used to swap to the next image
Timer ssUpdateTimer;

//images for the slideshow borders
Image imgTop, imgLeft, imgRight, imgBottom, imgBottomFade;

//current image being displayed
Image imgScreenshot;

//buttons for navigating
Button btnPlayPause, btnSettings, btnNext, btnPrev;

int x, y, r, w, h;
int displayX, displayY, displayHeight, displayWidth;

String PictureFolderPath;
String ViewerExePath;
String PathToCurrentPicture;

int PictureCount;
int CurrentPicture;
int ssInterval;

bool ControlsAreBright;

void ShowNextPicture(int offsetFromCurrent)
{
//increment the picture index
CurrentPicture += offsetFromCurrent;

//is this after the last one?
if (CurrentPicture >= PictureCount)
{
//go back to start
CurrentPicture = 0;
}
//is this before the first one
if (CurrentPicture < 0)
{
//wrap around to end
CurrentPicture = PictureCount - 1;
}

//try move to next image in list of files
bool anyMore;
anyMore = tblFiles.MoveTo(CurrentPicture);
if (anyMore)
{
//was another image, so get the filename
String s;
tblFiles.GetValue("Filename", s);
//show this picture
ShowPicture(s);
} else {
//no pictures in this folder, so show default image
ShowPicture("Default.Image.jpg");
}
}

//event handler to swap to the next picture
void ssUpdateTimer_OnTimer()
{
ShowNextPicture(1);
}

//click handler for when picture being shown is clicked
void imgScreenshot_OnClick()
{

if(ControlsAreBright){
Process.Start(ViewerExePath, PathToCurrentPicture);
//lblDebug.SetText("V = " + ViewerExePath);
//lblDebug1.SetText("P = " + PathToCurrentPicture);
}else{
//stop cycling through pictures
ssUpdateTimer.Stop();
// Fade in the controls
ControlsFade(false);
}
}

//click handler for the settings button
void btnSettings_OnClick()
{
SlideShowSettings s;
s.OnIntervalChanged = ScreenSettings_OnIntervalChanged;
s.OnFolderChanged = ScreenSelectFolder_OnSelectFolder;
s.OnViewerSelected = ScreenSelectViewer_OnSelectViewer;
FlowStack.Branch(s);
}

void ScreenSelectViewer_OnSelectViewer(String NewViewer)
{
ViewerExePath = NewViewer;
Attributes.Add("ViewerPath", NewViewer);
File.Write("Settings.txt", Attributes);
}

void ScreenSettings_OnIntervalChanged(ListItem selectedItem)
{
ssInterval = selectedItem.Attributes.Item("ID");
Attributes.Add("UpdateInterval", ssInterval);
File.Write("Settings.txt", Attributes);
}



//handler for when folder selected on the ScreenSelectFolder
void ScreenSelectFolder_OnSelectFolder(String FolderPath)
{
String path;

//save the path in the Attributes collection of this applet
Attributes.Add("FolderPath", FolderPath);
//save the folder path to file so if the user restarts their device it will still be the same
File.Write("Settings.txt", Attributes);

//get files in the folder
Path.GetFiles(FolderPath, tblFiles);
//make sure list doesn't include any directories
Path.RemoveDirectories(tblFiles);
//only keep image files
Path.KeepFiles(".jpg, .jpeg, .png, .bmp", tblFiles);

//how many pictures?
PictureCount = tblFiles.GetCount();
CurrentPicture = -1;

ShowNextPicture(1);
}

//click handler for the play button
void btnPlayPause_OnClick()
{
//start the picture cycle timer
ssUpdateTimer.StartSecondsTimer(ssInterval);
//hide the controls
ControlsFade(true);
}

//handler for the next picture button
void btnNext_OnClick()
{
//ensure auto cycling is stopped
ssUpdateTimer.Stop();

//show next picture
ShowNextPicture(1);
}

//click handler for previous button
void btnPrev_OnClick()
{
//ensure auto cycling is stopped
ssUpdateTimer.Stop();

//show previous picture
ShowNextPicture(-1);
}

//shows the picture specified in path
void ShowPicture(String path)
{
// Make a global copy of the path
PathToCurrentPicture = path;

//load the image and force it to the required dimensions
imgScreenshot.Surface.LoadFromFile(path, displayWidth, displayHeight);

//did it load?
if (imgScreenshot.Surface.GetWidth() <= 0)
{
//no, so use the default image
imgScreenshot.Surface.LoadFromFile("Default.Image.jpg");
}

//make sure the image control is positioned correctly
imgScreenshot.SetBounds(displayX, displayY);

//and make sure screen is forced to update
FlagScreenChanged();
}

//show or hide the navigation buttons
void ControlsFade(bool DirectionUp)
{
int Start, Finish;

if (DirectionUp)
{
if (ControlsAreBright == false)
{
return;
}
ControlsAreBright = false;
Start = 100;
Finish = 10;
}
else
{
if (ControlsAreBright == true)
{
return;
}
ControlsAreBright = true;
Start = 10;
Finish = 100;
}

//clear any previous animations that had been applied to these controls
//because don't want parallel animations running and fighting each other
btnPrev.AnimateClear();
btnPlayPause.AnimateClear();
btnSettings.AnimateClear();
btnNext.AnimateClear();

//fade the controls either in or out based on the Start/Finish values
btnPrev.AnimateFade(Start, Finish, 5);
btnPlayPause.AnimateFade(Start, Finish, 5, 1);
btnSettings.AnimateFade(Start, Finish, 5, 2);
btnNext.AnimateFade(Start, Finish, 5, 3);
}

//this method is called once for the Applet when it is being initially loaded
//and is where the controls for the applet are initialised, settings fetched from file etc
void Load()
{
x = 0;
y = 0;
w = GetWidth();
r = x + w;

//frame controls that will be displayed around the picture
y = 0;
imgTop.Surface.LoadFromFile("Frame.Top.jif");
Controls.Add(imgTop);
imgTop.SetBounds(x, y);
y += imgTop.GetHeight();
imgLeft.Surface.LoadFromFile("Frame.Left.jif");
Controls.Add(imgLeft);
imgLeft.SetBounds(x, y);
imgRight.Surface.LoadFromFile("Frame.Right.jif");
Controls.Add(imgRight);
r -= imgRight.GetWidth();
imgRight.SetBounds(r, y);
y += imgLeft.GetHeight();
imgBottom.Surface.LoadFromFile("Frame.Bottom.jif");
Controls.Add(imgBottom);
imgBottom.SetBounds(x, y);

//determine the display area limits - how much space is there to show the slideshow pictures?
displayHeight = GetHeight();
displayHeight -= ((imgTop.GetHeight() + imgBottom.GetHeight()) / 2);
displayWidth = GetWidth();
displayWidth -= ((imgLeft.GetWidth() + imgRight.GetWidth()) / 2);
displayX = imgLeft.GetWidth() / 2;
displayY = imgTop.GetHeight() / 2;

//load the default picture
imgScreenshot.Surface.LoadFromFile("Default.Image.jpg", displayWidth, displayHeight);
Controls.Add(imgScreenshot);
imgScreenshot.SendToBack();
imgScreenshot.SetBounds(displayX, displayY);
imgScreenshot.SetTabStop(true);
imgScreenshot.OnClick = imgScreenshot_OnClick;

x = 0;

//init the buttons

//load the images for normal and selected states
btnPrev.ImageSelected.LoadFromFile("Button.Previous.Selected.jif");
btnPrev.Image.LoadFromFile("Button.Previous.jif");
//add this button to be a direct child of the applet
Controls.Add(btnPrev);
//position it
y = GetHeight() - btnPrev.GetHeight();
btnPrev.SetBounds(x, y);
//provide an OnClick event handler so can respond to when the user clicks the button
btnPrev.OnClick = btnPrev_OnClick;

x += btnPrev.GetWidth();
btnPlayPause.ImageSelected.LoadFromFile("Button.Right.Arrow.Selected.jif");
btnPlayPause.Image.LoadFromFile("Button.Right.Arrow.jif");
Controls.Add(btnPlayPause);
btnPlayPause.SetBounds(x, y);
x += btnPlayPause.GetWidth();
btnPlayPause.OnClick = btnPlayPause_OnClick;

btnSettings.ImageSelected.LoadFromFile("Button.Settings.Selected.jif");
btnSettings.Image.LoadFromFile("Button.Settings.jif");
Controls.Add(btnSettings);
btnSettings.SetBounds(x, y);
x += btnSettings.GetWidth();
btnSettings.OnClick = btnSettings_OnClick;

btnNext.ImageSelected.LoadFromFile("Button.Next.Selected.jif");
btnNext.Image.LoadFromFile("Button.Next.jif");
Controls.Add(btnNext);
btnNext.SetBounds(x, y);
x += btnNext.GetWidth();
btnNext.OnClick = btnNext_OnClick;

//when playing go to next picture every 3 seconds
ssInterval = 3;
//set the event handler for OnTimer
ssUpdateTimer.OnTimer = ssUpdateTimer_OnTimer;

ControlsAreBright = true;

PictureCount = 0;

//load the settings into the Attributes collection
File.Read("Settings.txt", Attributes);
//read the last folder that was being viewed
PictureFolderPath = Attributes.Item("FolderPath");
ssInterval = Attributes.Item("UpdateInterval");
ViewerExePath = Attributes.Item("ViewerPath");

//is there are path previously saved?
if (PictureFolderPath.GetLength() > 0)
{
//yes, so make it load right now
ScreenSelectFolder_OnSelectFolder(PictureFolderPath);
}

//#region Debug
////Add some labels for debug messages
//int FontHeight;
//Controls.Add(lblDebug);
//lblDebug.SetAlign("Left", "Center");
//lblDebug.SetFont("Font.Small");
//FontHeight = lblDebug.GetFontHeight();
//y = 490; // Place them off the applet
//lblDebug.SetBounds(10, y, 400, FontHeight);
//Controls.Add(lblDebug1);
//lblDebug1.SetAlign("Left", "Center");
//lblDebug1.SetFont("Font.Small");
//y += FontHeight;
//y -= 5;
//lblDebug1.SetBounds(10, y, 400, lblDebug1.GetFontHeight());
//lblDebug.BringToFront();
//lblDebug1.BringToFront();

//lblDebug.SetText("Debug");
//lblDebug1.SetText("Debug1");
//DebugCount = 0;
//#endregion // Debug

}

//this method is called when the applet loses focus for some reason such as the user
//sliding to another applet, or going off to another screen after having this applet visible
void Deactivated()
{
//stop the update timer - no point loading more images if the user can't see them
ssUpdateTimer.Stop();
//show controls again
ControlsFade(false);
}

}
#endregion

#region Screens

class SlideShowSettings : ListScreen {
Label lblTitle;

String UpdateIntervalSeconds;

void Load() {
Controls.Add(lblTitle);
SetTitlePosition(lblTitle);
lblTitle.SetText("Parametres de Slideshow");

AddItem("Folder", "Selection du dossier");
AddItem("Interval", "Intervalle de Temps de la Mise a Jour");
AddItem("Viewer", "Selection de la visionneuse");

SetSoftKeys("Back", Terms.Get("Retour")"Done", Terms.Get("Valider"));

OnListItemClick = OnListItemClick_Handler;
}

void OnListItemClick_Handler(ListItem li, int x, int y) {
String id;
id = li.Attributes.Item("ID");

if (id == "Folder") {
//Select the folder containing the pictures
ScreenSelectFolder s;
s.OnSelectFolder = FolderSelectedEvent;
s.SearchType("Folder");
FlowStack.Branch(s);
} else if (id == "Interval") {
// Show the select interval screen
ScreenSelectUpdateInterval s;
s.SetSelectedItemID(UpdateIntervalSeconds);
s.OnDone = ScreenSelectUpdateInterval_OnDone;
FlowStack.Branch(s);
} else if (id == "Viewer") {
// Select an alternative 3rd party viewer
ScreenSelectFolder s;
s.OnExeSelect = ExeSelectEvent;
s.SearchType("Executable");
FlowStack.Branch(s);
}
}

Event OnIntervalChanged;
void ScreenSelectUpdateInterval_OnDone(ListItem selectedItem) {
UpdateIntervalSeconds = selectedItem.Attributes.Item("ID");
OnIntervalChanged(selectedItem);
}

Event OnFolderChanged;
void FolderSelectedEvent(String FolderPath) {
OnFolderChanged(FolderPath);
}

Event OnViewerSelected;
void ExeSelectEvent(String ExePath){
OnViewerSelected(ExePath);
}
}


class ScreenSelectUpdateInterval : ListScreen {
Label lblTitle;

void Load() {
Controls.Add(lblTitle);
SetTitlePosition(lblTitle);
lblTitle.SetText(Terms.Get("Selection du temps de mise a jour"));

AddItem("1", Terms.Get("1 Second"));
AddItem("2", Terms.Get("2 Seconds"));
AddItem("3", Terms.Get("3 Seconds"));
AddItem("4", Terms.Get("4 Seconds"));
AddItem("5", Terms.Get("5 Seconds"));
AddItem("6", Terms.Get("6 Seconds"));
AddItem("7", Terms.Get("7 Seconds"));

SetSoftKeys("Back", Terms.Get("Retour")"Done", Terms.Get("Valider"));

OnListItemClick = OnListItemClick_Handler;
}

Event OnDone;
void OnListItemClick_Handler(ListItem selectedItem, int x, int y) {
OnDone(selectedItem);
FlowStack.Return();
}
}




//screen that allows browsing through file system to select a folder/viewer
class ScreenSelectFolder : FileExplorerScreen
{
//title of the screen
Label lblTitle;
String TypeOfSearch; // Either "Folder" or "Executable"

//initialize the screen
void Load()
{
//init the title label
Controls.Add(lblTitle);
SetTitlePosition(lblTitle);

SetDisplayFileExt(false);
}

//event to raise when the user selects a folder
Event OnSelectFolder;
//event to raise when the user selects a viewer
Event OnExeSelect;

void FileClick(String ExePath){
OnExeSelect(ExePath);
FlowStack.Return();
}

//this method is called by the FileExplorerScreen when the user selects a folder
void FolderSelected(String filename)
{
//raise the event
OnSelectFolder(filename);

//return from the current screen
FlowStack.Return();
}

//this method is called by the FileExplorerScreen when the user navigates to each folder
//while trying to select one
void FolderChanged(String folder)
{
//get just the current folder name from the full path
String s;
s = Path.GetFilename(folder);

//are we at root?
if (s.GetLength() <= 0)
{
s = Terms.Get("Choisir le Dossier pour le Slideshow ");
}

//set the screen title
lblTitle.SetText(s);

SetSoftKeys("Back", Terms.Get("Retour") "Done", Terms.Get("Valider"));

}
void SearchType(String type){
if(type == "Folder"){
SetBasePath("\\");
SetStartPath("{MyPictures}");
SetMode("SelectImageFolder");
SetRestriction(".jpg, .jpeg, .png, .bmp");
} else if (type == "Executable") {
SetBasePath("{Programs}");
SetMode("Select");
SetRestriction(".exe, .lnk");

SetSoftKeys("Back", Terms.Get("Retour") "Done", Terms.Get("Valider"));
}
}
}

#endregion
Revenir en haut de page
Voir le profil de l'utilisateur Envoyer un message privé
Montrer les messages depuis:   
Poster un nouveau sujet   Répondre au sujet    SPF Index du Forum -> PointUI dans tous ses états Toutes les heures sont au format GMT + 1 Heure
Page 1 sur 1

 
Vous ne pouvez pas poster de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas voter dans les sondages de ce forum