static const int DETAIL_COUNT_MAX = 9;
ImageViewerForm::ImageViewerForm(void)
-: __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
-, __pLabel(null)
-, __pFooter(null)
-, __pScrollPanel(null)
-, __pDetail_Label(null)
-, __pLabelMessage(null)
-, __pPlayButton(null)
-, __pRenameButton(null)
-, __pDetailFooterItem(null)
-, __pGallery(null)
-, __pTimer(null)
-, __pContextMenuMore(null)
-, __pContextMenuCopy(null)
-, __pContextMenuSetAs(null)
-, __pContextMenuShare(null)
-, __pDeletePopup(null)
-, __visible(true)
-, __detail(true)
-, __startSlide(false)
-, __requestId(0)
-, __pPresentationModel(null)
+ : __shuffelStartIndex(0)
+ , __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
+ , __pLabel(null)
+ , __pFooter(null)
+ , __pScrollPanel(null)
+ , __pDetail_Label(null)
+ , __pLabelMessage(null)
+ , __pPlayButton(null)
+ , __pRenameButton(null)
+ , __pDetailFooterItem(null)
+ , __pGallery(null)
+ , __pTimer(null)
+ , __pShuffelTimer(null)
+ , __pContextMenuMore(null)
+ , __pContextMenuCopy(null)
+ , __pContextMenuSetAs(null)
+ , __pContextMenuShare(null)
+ , __pDeletePopup(null)
+ , __visible(true)
+ , __detail(true)
+ , __startSlide(false)
+ , __shuffle(false)
+ , __requestId(0)
+ , __pShuffledList(null)
+ , __pPresentationModel(null)
{
AppLogDebug("ENTER");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
__pContextMenuMore = new (std::nothrow) ContextMenu();
- __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
+ __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().height),
CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
AppLogDebug("ENTER : index(%d)", index);
GalleryItem* pGallery = new (std::nothrow) GalleryItem();
- String filePath = __pPresentationModel->GetFilePathAt(index);
- ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
+ int curIndex = index;
+
+ if(__shuffle == true && __pShuffledList != null)
+ {
+ curIndex = __pShuffledList[index];
+ }
+
+ String filePath = __pPresentationModel->GetFilePathAt(curIndex);
+ ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
Bitmap* pBitmap = pImageInfo->GetBitmapN();
+
if (pBitmap == null)
{
pBitmap = GetQuickThumbnailN(filePath);
bool
ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
{
- AppLogDebug("ENTER index(%d)", index);
- ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
+ AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
+ int curIndex = index;
+
+ if(__shuffle == true && __pShuffledList != null)
+ {
+ curIndex = __pShuffledList[index];
+ }
+
+
+ ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
pImageInfo->ClearBitmap();
delete pItem;
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
void
ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
{
- AppLogDebug("ENTER index(%d)", index);
+ AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
String filePath = __pPresentationModel->GetFilePathAt(index);
AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
void
ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
{
- AppLogDebug("ENTER");
+ AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
+
+ int index;
+
+ if(__shuffle == true)
+ {
+
+ if(__pShuffelTimer == null)
+ {
+ __pShuffelTimer = new (std::nothrow) Timer();
+ __pShuffelTimer->Construct(*this);
+ }
+ __pShuffelTimer->Start(1);
+ }
+ else
+ {
+ index = __pGallery->GetCurrentItemIndex();
+ SlideShowStopped(index);
+ }
+
+
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+ImageViewerForm::SlideShowStopped(int index)
+{
+ AppLog("ImageViewerForm::SlideShowStopped");
PowerManager::KeepScreenOnState(false, true);
- int index = __pGallery->GetCurrentItemIndex();
if (__visible == false)
{
__pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
Invalidate(true);
- AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
__pTimer = null;
}
+ if(__pShuffelTimer)
+ {
+ __pShuffelTimer->Cancel();
+ delete __pShuffelTimer;
+ __pShuffelTimer = null;
+ }
+
__pPresentationModel->ClearImageRequests();
__pPresentationModel->RemoveListener(*this);
__pPresentationModel->RemoveFileUpdateListener(*this);
__pContextMenuMore = null;
}
+ if(__pShuffledList != null)
+ {
+ free(__pShuffledList);
+ __pShuffledList = null;
+ }
+
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return E_SUCCESS;
void
ImageViewerForm::OnTimerExpired(Timer &timer)
{
- int repeatValue = 0;
- AppLogDebug("ENTER");
+ AppLog("ImageViewerForm::OnTimerExpired");
+
+ if(timer.Equals(*__pShuffelTimer) == true)
+ {
+ AppLog("OnTimerExpired __pShuffelTimer");
+ int curItemIndex = __pGallery->GetCurrentItemIndex();
+ int index = __pShuffledList[curItemIndex];
+
+ __shuffle = false;
+
+ __pGallery->UpdateGallery();
+
+ AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
+
+ __pGallery->SetCurrentItemIndex(index);
+ __pGallery->Draw();
+
+ SlideShowStopped(index);
+ return;
+ }
+
+ int repeatValue = 0;
+ int shuffleValue = 0;
+
if (__pPresentationModel->GetFileCount() > 1)
{
__pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
- ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
+ ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
- if (repeatValue == 0)
+ __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
+ ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
+
+
+ if(shuffleValue != 0)
+ {
+ __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
+ CreateShuffledList(__pPresentationModel->GetFileCount());
+ __shuffle = true;
+ }
+ else
+ {
+ __shuffelStartIndex = 0;
+ __shuffle = false;
+ }
+
+ if( repeatValue == 0)
{
__pGallery->StartSlideShow(false);
}
}
void
+ImageViewerForm::CreateShuffledList(int count)
+{
+ AppLogDebug("ImageViewerForm::CreateShuffledList ENTER");
+ if(__pShuffledList == null)
+ {
+ __pShuffledList = new (std::nothrow) int[count];
+ for(int i = 0; i < count; i++)
+ {
+ __pShuffledList[i] = i;
+ }
+ }
+ for(int i = count - 1; i > 1; i--)
+ {
+ int randomNum = Math::Rand() % (i+1);
+ int t = __pShuffledList[randomNum];
+ __pShuffledList[randomNum] = __pShuffledList[i];
+ __pShuffledList[i] = t;
+ }
+
+ for(int i = 0; i < count; i++)
+ {
+ AppLogDebug("ShuffeldList i = %d & Val = %d", i, __pShuffledList[i]);
+ }
+
+ AppLogDebug("ImageViewerForm::CreateShuffledList EXIT");
+}
+
+void
ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
{
AppLogDebug("ENTER");
if (__pPresentationModel->GetFileCount() > 1)
{
+ int shuffleValue;
+
__pGallery->UpdateGallery();
if (__detail == false)
__pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
+ __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
+ ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
+
+ if (shuffleValue != 0)
+ {
+ __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
+ CreateShuffledList(__pPresentationModel->GetFileCount());
+ __shuffle = true;
+ }
+ else
+ {
+ __shuffelStartIndex = 0;
+ __shuffle = false;
+ }
+
if (repeatValue == 0)
{
__pGallery->StartSlideShow(false);