1. Shuffle Implementation 2. fixed 31419
[apps/osp/ImageViewer.git] / src / IvImageViewerForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                IvImageViewerForm.cpp
19  * @brief               This is the implementation file for ImageViewerForm class.
20  */
21
22 #include <FApp.h>
23 #include "IvCommonUtil.h"
24 #include "IvImageInfo.h"
25 #include "IvImageViewerApp.h"
26 #include "IvImageViewerForm.h"
27 #include "IvImageViewerPresentationModel.h"
28 #include "IvResourceManager.h"
29 #include "IvSettingPresentationModel.h"
30 #include "IvSlideShowPopUp.h"
31 #include "IvTypes.h"
32
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Io;
41 using namespace Tizen::Media;
42 using namespace Tizen::System;
43 using namespace Tizen::Ui;
44 using namespace Tizen::Ui::Controls;
45 using namespace Tizen::Ui::Scenes;
46
47 static const unsigned int COLOR_HEADER_CONTORL_PANEL = Color32<0, 0, 0, 100>::Value;
48 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
49 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
51 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
52 static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
53
54 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
55
56 static const int W_PLAY_BUTTON = 160;
57 static const int H_PLAY_BUTTON = 160;
58
59 static const int GAP_W_POPUP_ITEM = 5;
60 static const int W_DELETE_POPUP = 600;
61 static const int H_DELETE_POPUP = 300;
62 static const int H_DELETE_LABEL = 180;
63 static const int Y_DELETE_BUTTON = 180;
64 static const int H_DELETE_BUTTON = 80;
65
66 static const Dimension DUMMY_IMAGE_DIMENSION    (720, 1280);
67 static const Rectangle DUMMY_IMAGE_RECTANGLE    (0, 0, 720, 1280);
68
69 static const int PAGE_NO_CONTENT_SEARCH = 1;
70 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
71
72 static const int FORMAT_BUFFER_SIZE = 256;
73
74 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
75 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
76 static const long long SINGLE_KILO_BYTE = 1024;
77
78 static const int Y_RENAME_BUTTON = 100;
79 static const int H_RENAME_BUTTON = 64;
80 static const int W_RENAME_BUTTON = 64;
81
82 static const int GAP_W_END_OF_LABEL = 60;
83 static const int X_DETAIL_FILEINFO_LABEL = 20;
84 static const int H_DETAIL_FILEINFO_LABEL = 50;
85 static const int H_DETAIL_MAIN_TEXT = 48;
86 static const int H_DETAIL_SUB_TEXT = 42;
87 static const int GAP_H_DETAIL_TEXT = 26;
88 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
89
90 static const int X_MORE = 55;
91
92 static const int DETAIL_SUB_FONT_SIZE = 32;
93 static const int DETAIL_MAIN_FONT_SIZE = 36;
94 static const int DETAIL_COUNT_MAX = 9;
95
96 ImageViewerForm::ImageViewerForm(void)
97         : __shuffelStartIndex(0)
98         , __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
99         , __pLabel(null)
100         , __pFooter(null)
101         , __pScrollPanel(null)
102         , __pDetail_Label(null)
103         , __pLabelMessage(null)
104         , __pPlayButton(null)
105         , __pRenameButton(null)
106         , __pDetailFooterItem(null)
107         , __pGallery(null)
108         , __pTimer(null)
109         , __pShuffelTimer(null)
110         , __pContextMenuMore(null)
111         , __pContextMenuCopy(null)
112         , __pContextMenuSetAs(null)
113         , __pContextMenuShare(null)
114         , __pDeletePopup(null)
115         , __visible(true)
116         , __detail(true)
117         , __startSlide(false)
118         , __shuffle(false)
119         , __requestId(0)
120         , __pShuffledList(null)
121         , __pPresentationModel(null)
122 {
123         AppLogDebug("ENTER");
124         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
125 }
126
127 ImageViewerForm::~ImageViewerForm(void)
128 {
129         AppLogDebug("ENTER");
130         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
131 }
132
133 result
134 ImageViewerForm::Initialize()
135 {
136         AppLogDebug("ENTER");
137
138         result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
139
140         __pPresentationModel = ImageViewerPresentationModel::GetInstance();
141
142         if (__pPresentationModel->GetFileCount() > 0)
143         {
144                 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
145                 {
146                         __startSlide = true;
147                 }
148         }
149
150         __pPresentationModel->AddFileUpdateListener(this);
151
152         __pSettingPresentationModel = SettingPresentationModel::GetInstance();
153
154         int startIndex = __pPresentationModel->GetStartIndex();
155         String filePath = __pPresentationModel->GetFilePathAt(startIndex);
156
157         if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
158         {
159                 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
160         }
161         else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
162         {
163                 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
164         }
165         else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
166         {
167                 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
168         }
169         else
170         {
171                 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
172         }
173
174         if (filePath == EMPTY_SPACE)
175         {
176                 MessageBox messageBox;
177                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
178                                 3000);
179                 int modalResult = 0;
180                 messageBox.ShowAndWait(modalResult);
181
182                 UiApp* pApp = UiApp::GetInstance();
183                 pApp->Terminate();
184         }
185
186         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
187
188         return r;
189 }
190
191 result
192 ImageViewerForm::OnInitializing(void)
193 {
194         AppLogDebug("ENTER");
195         result r = E_SUCCESS;
196         SetFormBackEventListener(this);
197         __pPresentationModel->AddListener(this);
198
199         __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
200
201         if(__pLabel == null)
202         {
203                 return E_FAILURE;
204         }
205         __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
206         SetControlAlwaysOnTop(*__pLabel,true);
207         int allCount = __pPresentationModel->GetFileCount();
208         int index = 1 ;
209         String displayText;
210         displayText.Append(index);
211         displayText.Append("/");
212         displayText.Append(allCount);
213
214         __pLabel->SetText(displayText);
215
216         CreateGallery();
217         InitializeDisplay(__initializeDisplayModeCurrent);
218         InitializePanelDetail();
219         InitializePopup();
220
221         __pPopUp = new (std::nothrow) SlideShowPopUp();
222
223         if (__pPopUp != null)
224         {
225                 __pPopUp->Initialize();
226                 __pPopUp->SetEventListner(this);
227                 AddControl(*__pPopUp);
228         }
229
230
231         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
232                         || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
233                         || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
234         {
235                 int index = __pPresentationModel->GetStartIndex();
236                 __pGallery->UpdateGallery();
237                 __pGallery->SetCurrentItemIndex(index);
238                 __pGallery->Draw();
239
240                 String filePath = __pPresentationModel->GetFilePathAt(index);
241                 __pPresentationModel->RequestImage(filePath);
242         }
243         else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
244         {
245                 RequestDecodeUrl();
246         }
247
248         if (__startSlide)
249         {
250                 __pTimer = new (std::nothrow) Timer();
251                 __pTimer->Construct(*this);
252                 __pTimer->Start(1);
253         }
254
255         AddOrientationEventListener(*this);
256         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
257
258         return r;
259 }
260
261 result
262 ImageViewerForm::OnInitialized(void)
263 {
264         AppLogDebug("ENTER");
265         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
266
267         return E_SUCCESS;
268 }
269
270 void
271 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
272 {
273         AppLogDebug("ENTER");
274         if (__detail == false)
275         {
276                 ShowPanelDetail(true);
277         }
278         else
279         {
280                 ShowPanelDetail(false);
281         }
282
283         Rectangle clientRect = GetClientAreaBounds();
284         Rectangle rect = GetBounds();
285
286         __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
287         __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
288                         clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
289
290         Invalidate(true);
291         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
292 }
293
294 void
295 ImageViewerForm::InitializeDisplay(AppControlMode status)
296 {
297         AppLogDebug("ENTER");
298
299         String strItemIdxText;
300
301         __pFooter = GetFooter();
302         __pFooter->AddActionEventListener(*this);
303         __pFooter->RemoveAllItems();
304
305         GetLabelText(0, strItemIdxText);
306         Rectangle rect = GetClientAreaBounds();
307
308
309         if (status == APPCONTROL_MODE_NORMAL)
310         {
311                 __pPlayButton = new (std::nothrow) Button();
312                 if (__pPlayButton != null)
313                 {
314                         Rectangle clientRect = GetClientAreaBounds();
315
316                         __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
317                                         clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
318                         __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
319                         AddControl(*__pPlayButton);
320
321                         Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
322                         __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
323                         delete pNormalBackgroundBitmap;
324
325                         Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
326                         __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
327                         delete pPressedBackgroundBitmap;
328
329                         __pPlayButton->AddActionEventListener(*this);
330                         __pPlayButton->SetShowState(false);
331                 }
332
333                 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
334                 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
335                 __pFooter->SetBackButton();
336
337                 FooterItem footerItem1;
338                 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
339                 Bitmap* pFooterItemShareNomal =
340                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
341                 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
342
343                 FooterItem footerItem2;
344                 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
345                 Bitmap* pFooterItemDeleteNomal =
346                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
347                 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
348
349                 __pFooter->AddItem(footerItem1);
350                 __pFooter->AddItem(footerItem2);
351
352                 delete pFooterItemShareNomal;
353                 delete pFooterItemDeleteNomal;
354
355                 ButtonItem buttonItemMore;
356                 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
357                 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
358                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
359                 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
360                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
361                 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
362         }
363         else if (status == APPCONTROL_MODE_WEB_LINK)
364         {
365                 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
366                 __pFooter->SetBackButton();
367
368                 FooterItem  footerItem1;
369                 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
370                 Bitmap* pFooterItemShareNomal =
371                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
372                 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
373
374                 FooterItem  footerItem2;
375                 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
376                 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
377                 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
378
379                 __pFooter->AddItem(footerItem1);
380                 __pFooter->AddItem(footerItem2);
381
382                 delete pFooterItemShareNomal;
383                 delete pFooterItemDownlordNomal;
384
385                 ButtonItem buttonItemMore;
386                 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
387                 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
388                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
389                 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
390                                 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
391                 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
392
393                 __pFooter->AddItem(footerItem1);
394                 __pFooter->AddItem(footerItem2);
395         }
396         else if (status == APPCONTROL_MODE_CROP)
397         {
398                 FooterItem  footerItem1;
399                 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
400                 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
401                 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
402
403                 FooterItem  footerItem2;
404                 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
405                 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
406                 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
407
408                 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
409                 __pFooter->AddItem(footerItem1);
410                 __pFooter->AddItem(footerItem2);
411
412                 delete pfooterItem1;
413                 delete pfooterItem2;
414         }
415         else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
416         {
417                 __pPlayButton = new (std::nothrow) Button();
418                 if (__pPlayButton != null)
419                 {
420                         Rectangle clientRect = GetClientAreaBounds();
421
422                         __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
423                                         clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
424                         __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
425                         AddControl(*__pPlayButton);
426
427                         Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
428                         __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
429                         delete pNormalBackgroundBitmap;
430
431                         Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
432                         __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
433                         delete pPressedBackgroundBitmap;
434
435                         __pPlayButton->AddActionEventListener(*this);
436                         __pPlayButton->SetShowState(false);
437                 }
438
439                 __pFooter->SetBackButton();
440         }
441
442         String filePath = __pPresentationModel->GetFilePathAt(0);
443         ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
444         if (contentType == CONTENT_TYPE_VIDEO)
445         {
446                 __pPlayButton->SetShowState(true);
447         }
448         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
449 }
450
451 void
452 ImageViewerForm::GetLabelText(int index, String &page)
453 {
454         AppLogDebug("ENTER");
455         int allCount = __pPresentationModel->GetFileCount();
456         String pStr = __pPresentationModel->GetFilePathAt(index);
457         page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
458         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
459 }
460
461 result
462 ImageViewerForm::DeleteImageFile()
463 {
464         AppLogDebug("ENTER");
465         int currentIndex = __pGallery->GetCurrentItemIndex();
466
467         String strItemText(EMPTY_SPACE);
468         String strItemIdxText(EMPTY_SPACE);
469         int countPath = __pPresentationModel->GetFileCount();
470         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
471
472         if (filePath.GetLength() == 0)
473         {
474                 UiApp* pApp = UiApp::GetInstance();
475                 pApp->Terminate();
476                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
477
478                 return E_FAILURE;
479         }
480
481         result r = File::Remove(filePath);
482         if (r != E_SUCCESS)
483         {
484                 MessageBox messageBox;
485                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
486                                 MSGBOX_STYLE_NONE, 3000);
487                 int modalResult = 0;
488                 messageBox.ShowAndWait(modalResult);
489                 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
490
491                 return r;
492         }
493
494         if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
495                         || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
496         {
497                 ContentManager::ScanFile(filePath);
498         }
499
500         __pPresentationModel->DeleteFilePathAt(currentIndex);
501         if (countPath == 1)
502         {
503                 UiApp* pApp = UiApp::GetInstance();
504                 pApp->Terminate();
505                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
506
507                 return r;
508         }
509         else if ((countPath - 1) == currentIndex)
510         {
511                 __pGallery->SetCurrentItemIndex(--currentIndex);
512         }
513
514         __pGallery->UpdateGallery();
515         filePath = __pPresentationModel->GetFilePathAt(currentIndex);
516         __pPresentationModel->RequestImage(filePath);
517
518         GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
519
520         if (__visible == true)
521         {
522                 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
523
524                 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
525                 {
526                         __pPlayButton->SetShowState(false);
527                 }
528                 else
529                 {
530                         __pPlayButton->SetShowState(true);
531                 }
532         }
533         Invalidate(true);
534         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
535
536         return r;
537 }
538
539 void
540 ImageViewerForm::CallVideoPlayer(void)
541 {
542         AppLogDebug("ENTER");
543         int index = __pGallery->GetCurrentItemIndex();
544         String filePath = __pPresentationModel->GetFilePathAt(index);
545         filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
546
547         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
548                         new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
549         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
550 }
551
552 void
553 ImageViewerForm::CreateGallery(void)
554 {
555         AppLogDebug("ENTER");
556         Rectangle clientRect = GetClientAreaBounds();
557         Rectangle rect = GetBounds();
558
559         __pGallery = new (std::nothrow) Gallery();
560         __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
561         __pGallery->SetName(L"GalleryControl");
562         __pGallery->SetItemProvider(*this);
563         __pGallery->AddGalleryEventListener(*this);
564         __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
565         AddControl(*__pGallery);
566         __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
567
568         SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
569
570         switch (effect)
571         {
572         case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
573                 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
574                 break;
575         case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
576                 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
577                 break;
578         case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
579                 break;
580         }
581
582         __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
583
584         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
585 }
586
587 result
588 ImageViewerForm::InitializePanelDetail()
589 {
590         AppLogDebug("ENTER");
591         __pScrollPanel = new (std::nothrow) ScrollPanel();
592
593         String arrayId[DETAIL_COUNT_MAX] =
594         {
595                 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
596                 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
597                 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
598         };
599
600         if (__pScrollPanel == null)
601         {
602                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
603
604                 return E_INVALID_STATE;
605         }
606
607         Rectangle clientRect = GetClientAreaBounds();
608         result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
609         if (r != E_SUCCESS)
610         {
611                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
612
613                 return E_INVALID_STATE;
614         }
615
616         __pDetail_Label = new (std::nothrow) Label();
617         __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
618         __pScrollPanel->AddControl(*__pDetail_Label);
619         __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
620         __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
621         __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
622         __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
623
624         for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
625         {
626                 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
627                 __pDetail_FileInfo_Label[i]->Construct(
628                                 Rectangle(X_DETAIL_FILEINFO_LABEL,
629                                                 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
630                                                 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
631                 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
632
633                 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
634                 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
635                 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
636                 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
637
638                 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
639
640                 if (i == DETAIL_COUNT_MAX - 1)
641                 {
642                         __pDetail_FileInfo_Value_Label[i]->Construct(
643                                         Rectangle(X_DETAIL_FILEINFO_LABEL,
644                                                         GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
645                                                         clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
646                 }
647                 else
648                 {
649                         __pDetail_FileInfo_Value_Label[i]->Construct(
650                                         Rectangle(X_DETAIL_FILEINFO_LABEL,
651                                                         GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
652                                                         clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
653                 }
654
655                 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
656
657                 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
658                 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
659                 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
660                 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
661         }
662
663         __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
664         __pScrollPanel->SetShowState(false);
665
666         __pRenameButton = new (std::nothrow) Button();
667         Rectangle rect = GetBounds();
668         __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
669         __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
670         __pRenameButton->AddActionEventListener(*this);
671
672         Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
673         Bitmap* pIconBackground =
674                         ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
675         Bitmap* pIconPressed =
676                         ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
677
678         if (pIcon != null && pIconPressed != null && pIconBackground != null)
679         {
680                 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
681                 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
682                 Point iconPosition(0, 0);
683                 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
684                 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
685         }
686         else
687         {
688                 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
689                 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
690         }
691         delete pIcon;
692         delete pIconPressed;
693         delete pIconBackground;
694
695         __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
696         __pScrollPanel->AddControl(*__pRenameButton);
697
698
699         AddControl(*__pScrollPanel);
700         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
701
702         return E_SUCCESS;
703 }
704
705 result
706 ImageViewerForm::InitializePopup(void)
707 {
708         AppLogDebug("ENTER");
709         if (__pDeletePopup == null)
710         {
711                 __pDeletePopup = new (std::nothrow) Popup();
712                 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
713
714                 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
715
716                 Label* pLabel = new (std::nothrow) Label();
717                 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
718                                 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
719
720                 Button* pDeleteButton = new (std::nothrow) Button();
721                 pDeleteButton->Construct(
722                                 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
723                                 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
724                 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
725                 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
726                 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
727                 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
728                 pDeleteButton->AddActionEventListener(*this);
729
730                 Button* pCancelButton = new (std::nothrow) Button();
731                 pCancelButton->Construct(
732                                 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
733                                                 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
734                                                 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
735                 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
736                 pCancelButton->AddActionEventListener(*this);
737
738                 __pDeletePopup->AddControl(*pLabel);
739                 __pDeletePopup->AddControl(*pDeleteButton);
740                 __pDeletePopup->AddControl(*pCancelButton);
741         }
742         else
743         {
744                 __pDeletePopup->SetShowState(true);
745                 __pDeletePopup->Show();
746         }
747         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
748
749         return E_SUCCESS;
750 }
751
752 result
753 ImageViewerForm::InitializeContextMenuMore(void)
754 {
755         AppLogDebug("ENTER");
756         int currentIndex = __pGallery->GetCurrentItemIndex();
757         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
758
759         ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
760
761         if (__pContextMenuMore != null)
762         {
763                 delete __pContextMenuMore;
764                 __pContextMenuMore = null;
765         }
766
767         __pContextMenuMore = new (std::nothrow) ContextMenu();
768
769         __pContextMenuMore->Construct(Point(X_MORE,  GetClientAreaBounds().height),
770                         CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
771
772         if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
773         {
774                 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
775                                 ACTION_ID_CONTEXTMENU_SET_AS);
776                 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
777         }
778
779         if (__pGallery->GetItemCount() > 1)
780         {
781                 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
782                                 ACTION_ID_FOOTER_BUTTON_SLIDE);
783         }
784         __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
785                         ACTION_ID_FOOTER_BUTTON_DETAILS);
786         __pContextMenuMore->SetShowState(false);
787         __pContextMenuMore->AddActionEventListener(*this);
788         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
789
790         return E_SUCCESS;
791 }
792
793 result
794 ImageViewerForm::InitializeContextMenuSetAs(void)
795 {
796         AppLogDebug("ENTER");
797
798         if (__pContextMenuSetAs != null)
799         {
800                 delete __pContextMenuSetAs;
801                 __pContextMenuSetAs = null;
802         }
803
804         __pContextMenuSetAs = new (std::nothrow) ContextMenu();
805         __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
806                         CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
807
808         __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
809                         ACTION_ID_CONTEXTMENU_HOME);
810         __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
811                         ACTION_ID_CONTEXTMENU_LOCK);
812         __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
813         __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
814                         ACTION_ID_CONTEXTMENU_CALLER);
815         __pContextMenuSetAs->AddActionEventListener(*this);
816         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
817
818         return E_SUCCESS;
819 }
820
821 result
822 ImageViewerForm::InitializeContextMenuShare(void)
823 {
824         AppLogDebug("ENTER");
825         if (__pContextMenuShare != null)
826         {
827                 delete __pContextMenuShare;
828                 __pContextMenuShare = null;
829         }
830         __pContextMenuShare = new (std::nothrow) ContextMenu();
831         __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
832                         GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
833                         CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
834
835         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
836                         ACTION_ID_CONTEXTMENU_MESSAGE);
837         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
838         __pContextMenuShare->AddActionEventListener(*this);
839         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
840
841         return E_SUCCESS;
842 }
843
844 long long
845 ImageViewerForm::GetFileSize(String filePath)
846 {
847         AppLogDebug("ENTER");
848         FileAttributes attr;
849         long long size = 0;
850
851         result r = File::GetAttributes(filePath, attr);
852         if (r != E_SUCCESS)
853         {
854                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
855
856                 return 0;
857         }
858         size = attr.GetFileSize();
859         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
860
861         return size;
862 }
863
864 result
865 ImageViewerForm::SetDetailInfo(void)
866 {
867         AppLogDebug("ENTER");
868
869         Rectangle clientRect = GetClientAreaBounds();
870         __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
871
872         int currentIndex = __pGallery->GetCurrentItemIndex();
873         String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
874
875         ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
876
877         String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
878
879         strResult[0] = __pPresentationModel->GetFileName(strFilePath);
880         strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
881
882         FileAttributes attr;
883         result r = File::GetAttributes(strFilePath, attr);
884         if (r == E_SUCCESS)
885         {
886                 long long nSize = attr.GetFileSize();
887                 DateTime dateTime = attr.GetDateTime();
888                 strResult[2] = dateTime.ToString();
889
890                 if (nSize > SINGLE_GIGA_BYTE)
891                 {
892                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
893                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
894                 }
895                 else if (nSize > SINGLE_MEGA_BYTE)
896                 {
897                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
898                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
899                 }
900                 else if (nSize > SINGLE_KILO_BYTE)
901                 {
902                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
903                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
904                 }
905                 else
906                 {
907                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
908                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
909                 }
910         }
911         else
912         {
913                 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
914                 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
915         }
916
917         strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
918         strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919         strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
920         strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
921         strResult[8] = strFilePath;
922         String fileName = File::GetFileName(strFilePath);
923         strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
924
925         if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
926         {
927                 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
928         }
929
930         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
931         {
932                 strResult[0] = __downLordFileName;
933         }
934         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
935         {
936                 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
937
938                 if (pImgMeta != null)
939                 {
940                         ImageContentInfo imageContentInfo;
941                         r = imageContentInfo.Construct(&strFilePath);
942                         if (r == E_SUCCESS)
943                         {
944                                 strResult[1] = imageContentInfo.GetMediaFormat();
945                                 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
946                                                 pImgMeta->GetHeight());
947
948                                 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
949                                 {
950                                         strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
951                                 }
952
953                                 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
954                                 {
955                                         strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
956                                         strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
957                                 }
958                         }
959                         delete pImgMeta;
960                 }
961         }
962         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
963         {
964                 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
965                 if (pVideoMeta != null)
966                 {
967                         VideoContentInfo videoContentInfo;
968                         r = videoContentInfo.Construct(&strFilePath);
969                         if (r == E_SUCCESS)
970                         {
971                                 strResult[1] = videoContentInfo.GetMediaFormat();
972                                 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
973                                                 pVideoMeta->GetHeight());
974                                 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
975                                 {
976                                         strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
977                                 }
978                         }
979                 }
980         }
981
982         for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
983         {
984                 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
985                 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
986         }
987
988         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
989         {
990                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
991                 return r;
992         }
993
994         Rectangle rect = GetBounds();
995         __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
996
997         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
998
999         return r;
1000 }
1001
1002 result
1003 ImageViewerForm::ShowPanelDetail(bool showStatus)
1004 {
1005         AppLogDebug("ENTER");
1006         if (showStatus)
1007         {
1008                 SetDetailInfo();
1009                 __pScrollPanel->SetShowState(true);
1010                 __detail = false;
1011         }
1012         else
1013         {
1014                 __pScrollPanel->SetShowState(false);
1015                 __detail = true;
1016         }
1017         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1018
1019         return E_SUCCESS;
1020 }
1021
1022 result
1023 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1024 {
1025         AppLogDebug("ENTER");
1026         FooterItem footerItem;
1027         footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1028         Bitmap* pfooterItem = null;
1029
1030         if (isChanged)
1031         {
1032                 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1033                 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1034         }
1035         else
1036         {
1037                 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1038                 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1039         }
1040
1041         pFooter->SetItemAt(position, footerItem);
1042         pFooter->Invalidate(true);
1043
1044         delete pfooterItem;
1045         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1046
1047         return E_SUCCESS;
1048 }
1049
1050 void
1051 ImageViewerForm::DownloadFile(void)
1052 {
1053         AppLogDebug("ENTER");
1054         String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1055         if (File::IsFileExist(DestPath) == false)
1056         {
1057                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1058                 return;
1059         }
1060
1061         ContentId contentId;
1062         ContentManager contentManager;
1063         contentManager.Construct();
1064
1065         ImageContentInfo imageContentInfo;
1066         imageContentInfo.Construct(null);
1067
1068         imageContentInfo.SetKeyword(L"platform, tizen");
1069         String sourcePath = DestPath;
1070         String destPath = Environment::GetMediaPath();
1071         destPath.Append(FOLDER_PATH_DOWNLOADS);
1072         destPath.Append(__downLordFileName);
1073
1074         contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1075         ImageViewerForm::OnFormBackRequested(*this);
1076         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1077 }
1078
1079 int
1080 ImageViewerForm::GetItemCount(void)
1081 {
1082         AppLogDebug("ENTER");
1083         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1084
1085         return __pPresentationModel->GetFileCount();
1086 }
1087
1088 GalleryItem*
1089 ImageViewerForm::CreateItem(int index)
1090 {
1091         AppLogDebug("ENTER : index(%d)", index);
1092         GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1093
1094         int curIndex = index;
1095
1096         if(__shuffle == true && __pShuffledList != null)
1097         {
1098                 curIndex = __pShuffledList[index];
1099         }
1100
1101         String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1102         ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1103         Bitmap* pBitmap = pImageInfo->GetBitmapN();
1104
1105         if (pBitmap == null)
1106         {
1107                 pBitmap = GetQuickThumbnailN(filePath);
1108
1109                 if (pBitmap == null)
1110                 {
1111                         pBitmap = new (std::nothrow) Bitmap();
1112                         pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1113                 }
1114         }
1115         pGallery->Construct(*pBitmap, filePath);
1116         delete pBitmap;
1117         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1118
1119         return pGallery;
1120 }
1121
1122 bool
1123 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1124 {
1125         AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1126         int curIndex = index;
1127
1128         if(__shuffle == true && __pShuffledList != null)
1129         {
1130                 curIndex = __pShuffledList[index];
1131         }
1132
1133
1134         ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1135         pImageInfo->ClearBitmap();
1136         delete pItem;
1137         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1138
1139         return true;
1140 }
1141
1142 void
1143 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1144 {
1145         AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1146
1147         String filePath = __pPresentationModel->GetFilePathAt(index);
1148         AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1149         __pPresentationModel->RequestImage(filePath);
1150
1151         String strItemIdxText;
1152         GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1153         __pLabel->SetText(strItemIdxText);
1154
1155         if (__visible == true)
1156         {
1157                 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1158                 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1159                 {
1160                         __pPlayButton->SetShowState(true);
1161                 }
1162                 else
1163                 {
1164                         __pPlayButton->SetShowState(false);
1165                 }
1166         }
1167
1168         Invalidate(true);
1169         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1170 }
1171
1172 void
1173 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1174 {
1175         AppLogDebug("ENTER");
1176
1177         String filePath = __pPresentationModel->GetFilePathAt(index);
1178         ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1179
1180         if (__visible == true)
1181         {
1182                 if (contentType == CONTENT_TYPE_VIDEO)
1183                 {
1184                         __pPlayButton->SetShowState(false);
1185                 }
1186
1187                 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1188                 __pLabel->SetShowState(false);
1189                 __visible = false;
1190         }
1191         else
1192         {
1193                 if (contentType == CONTENT_TYPE_VIDEO)
1194                 {
1195                         __pPlayButton->SetShowState(true);
1196                 }
1197
1198                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1199                 __pLabel->SetShowState(true);
1200                 __visible = true;
1201
1202                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1203                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1204         }
1205
1206         Rectangle clientRect = GetClientAreaBounds();
1207         Rectangle rect = GetBounds();
1208         __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1209         Invalidate(true);
1210         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1211 }
1212
1213 void
1214 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1215 {
1216         AppLogDebug("ENTER");
1217         PowerManager::KeepScreenOnState(true, false);
1218         if (__visible  == true)
1219         {
1220                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1221                 __pLabel->SetShowState(false);
1222
1223                 int index = __pGallery->GetCurrentItemIndex();
1224                 String filePath = __pPresentationModel->GetFilePathAt(index);
1225                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1226
1227                 if (contentType == CONTENT_TYPE_VIDEO)
1228                 {
1229                         __pPlayButton->SetShowState(false);
1230                 }
1231
1232                 __visible = false;
1233         }
1234
1235         Rectangle clientRect = GetClientAreaBounds();
1236         Rectangle rect = GetBounds();
1237         __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1238         Invalidate(true);
1239         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1240 }
1241
1242 void
1243 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1244 {
1245         AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1246
1247         int index;
1248
1249         if(__shuffle == true)
1250         {
1251
1252                 if(__pShuffelTimer == null)
1253                 {
1254                         __pShuffelTimer = new (std::nothrow) Timer();
1255                         __pShuffelTimer->Construct(*this);
1256                 }
1257                 __pShuffelTimer->Start(1);
1258         }
1259         else
1260         {
1261                 index = __pGallery->GetCurrentItemIndex();
1262                 SlideShowStopped(index);
1263         }
1264
1265
1266         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1267 }
1268
1269 void
1270 ImageViewerForm::SlideShowStopped(int index)
1271 {
1272         AppLog("ImageViewerForm::SlideShowStopped");
1273         PowerManager::KeepScreenOnState(false, true);
1274
1275         if (__visible == false)
1276         {
1277                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1278                 __pLabel->SetShowState(true);
1279                 String filePath = __pPresentationModel->GetFilePathAt(index);
1280                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1281                 if (contentType == CONTENT_TYPE_VIDEO)
1282                 {
1283                         __pPlayButton->SetShowState(true);
1284                 }
1285
1286                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1287                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1288
1289                 __visible = true;
1290         }
1291
1292         String strItemIdxText;
1293         GetLabelText(index, strItemIdxText);
1294         __pLabel->SetText(strItemIdxText);
1295
1296
1297         Rectangle clientRect = GetClientAreaBounds();
1298         Rectangle rect = GetBounds();
1299         __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1300
1301         Invalidate(true);
1302 }
1303
1304 void
1305 ImageViewerForm::OnUpdateContentList(void)
1306 {
1307 }
1308
1309 result
1310 ImageViewerForm::OnTerminating(void)
1311 {
1312         AppLogDebug("ENTER");
1313
1314         if (__pTimer != null)
1315         {
1316                 __pTimer->Cancel();
1317                 delete __pTimer;
1318                 __pTimer = null;
1319         }
1320
1321         if(__pShuffelTimer)
1322         {
1323                 __pShuffelTimer->Cancel();
1324                 delete __pShuffelTimer;
1325                 __pShuffelTimer = null;
1326         }
1327
1328         __pPresentationModel->ClearImageRequests();
1329         __pPresentationModel->RemoveListener(*this);
1330         __pPresentationModel->RemoveFileUpdateListener(*this);
1331
1332         if (__pContextMenuCopy != null)
1333         {
1334                 delete __pContextMenuCopy;
1335                 __pContextMenuCopy = null;
1336         }
1337
1338         if (__pContextMenuSetAs != null)
1339         {
1340                 delete __pContextMenuSetAs;
1341                 __pContextMenuSetAs = null;
1342         }
1343
1344         if (__pDeletePopup != null)
1345         {
1346                 delete __pDeletePopup;
1347                 __pDeletePopup = null;
1348         }
1349
1350         if (__pContextMenuShare != null)
1351         {
1352                 delete __pContextMenuShare;
1353                 __pContextMenuShare = null;
1354         }
1355
1356         if (__pContextMenuMore != null)
1357         {
1358                 delete __pContextMenuMore;
1359                 __pContextMenuMore = null;
1360         }
1361
1362         if(__pShuffledList != null)
1363         {
1364                 free(__pShuffledList);
1365                 __pShuffledList = null;
1366         }
1367
1368         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1369
1370         return E_SUCCESS;
1371 }
1372
1373 void
1374 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1375 {
1376         AppLogDebug("ENTER actionId(%d)", actionId);
1377         SceneManager* pSceneManager = SceneManager::GetInstance();
1378         InitShowGallery();
1379
1380         switch (actionId)
1381         {
1382         case ACTION_ID_FOOTER_MORE:
1383         {
1384                 InitializeContextMenuMore();
1385
1386                 __pContextMenuMore->SetShowState(true);
1387                 __pContextMenuMore->Show();
1388         }
1389         break;
1390         case ACTION_ID_CONTEXTMENU_SET_AS:
1391                 InitializeContextMenuSetAs();
1392
1393                 __pContextMenuSetAs->SetShowState(true);
1394                 __pContextMenuSetAs->Show();
1395                 break;
1396         case ACTION_ID_FOOTER_BUTTON_SHARE:
1397                 InitializeContextMenuShare();
1398
1399                 __pContextMenuShare->SetShowState(true);
1400                 __pContextMenuShare->Show();
1401                 break;
1402         case ACTION_ID_FOOTER_BUTTON_DELETE:
1403                 __pDeletePopup->SetShowState(true);
1404                 __pDeletePopup->Show();
1405                 break;
1406         case ACTION_ID_FOOTER_BUTTON_SLIDE:
1407         {
1408                 if (__pPopUp != null)
1409                 {
1410                         __pPopUp->SetShowState(true);
1411                         __pPopUp->Show();
1412                 }
1413
1414                 break;
1415         }
1416         case ACTION_ID_FOOTER_BUTTON_CROP:
1417         {
1418                 String filePath;
1419                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1420                 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1421                 pList->Add(new (std::nothrow) String(filePath));
1422                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1423         }
1424         break;
1425         case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1426         {
1427                 int currentIndex = __pGallery->GetCurrentItemIndex();
1428                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1429                 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1430                 __pPresentationModel->SetImageRotateStatus(true);
1431                 RotateImage(filePath, rotateMode);
1432                 __pPresentationModel->RequestImage(filePath);
1433                 //Invalidate(true);
1434                 ContentManager contentManager;
1435                 contentManager.Construct();
1436                 contentManager.ScanFile(filePath);
1437         }
1438         break;
1439         case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1440         {
1441                 int currentIndex = __pGallery->GetCurrentItemIndex();
1442                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1443                 RotateMode rotateMode = ROTATE_MODE_LEFT;
1444                 __pPresentationModel->SetImageRotateStatus(true);
1445                 RotateImage(filePath, rotateMode);
1446                 __pPresentationModel->RequestImage(filePath);
1447                 //Invalidate(true);
1448                 ContentManager contentManager;
1449                 contentManager.Construct();
1450                 contentManager.ScanFile(filePath);
1451         }
1452         break;
1453         case ACTION_ID_FOOTER_BUTTON_DETAILS:
1454         {
1455                 ShowPanelDetail(__detail);
1456                 break;
1457         }
1458         case ACTION_ID_FOOTER_BUTTON_BACK:
1459                 ImageViewerForm::OnFormBackRequested(*this);
1460                 break;
1461         case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1462                 DownloadFile();
1463                 break;
1464         case ACTION_ID_FOOTER_BUTTON_SAVE:
1465                 break;
1466         case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1467         {
1468                 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1469                 pSelectedIndex->Construct();
1470                 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1471                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1472                 break;
1473         }
1474         case ACTION_ID_CONTEXTMENU_HOME:
1475         {
1476                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1477                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1478                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1479                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1480                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1481                 break;
1482         }
1483         case ACTION_ID_CONTEXTMENU_LOCK:
1484         {
1485                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1486                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1487                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1488                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1489                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1490                 break;
1491         }
1492         case ACTION_ID_CONTEXTMENU_CALLER:
1493         {
1494                 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1495                 pDataList->Construct();
1496                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1497                                 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1498                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1499                                 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1500                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1501                                 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1502
1503                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1504                                 APPCONTROL_OPERATION_ID_PICK, null, null, pDataList, this);
1505                 break;
1506         }
1507
1508         case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1509         {
1510                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1511                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1512                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1513                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1514                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1515                 break;
1516                 break;
1517         }
1518
1519         case ACTION_ID_CONTEXTMENU_EMAIL:
1520         {
1521                 OnRequestEmailAction();
1522                 break;
1523         }
1524         case ACTION_ID_CONTEXTMENU_MESSAGE:
1525         {
1526                 OnRequestMessagesAction();
1527                 break;
1528         }
1529         case ACTION_ID_CONTEXTMENU_COPY:
1530         {
1531                 int currentIndex = __pGallery->GetCurrentItemIndex();
1532                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1533
1534                 ClipboardItem item;
1535                 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1536                 Clipboard* pClipboard = Clipboard::GetInstance();
1537                 pClipboard->CopyItem(item);
1538                 break;
1539         }
1540         case ACTION_ID_DELETE_POPUP_DEL:
1541         {
1542                 __pDeletePopup->SetShowState(false);
1543                 __pDeletePopup->Show();
1544                 DeleteImageFile();
1545
1546                 if (__detail == false)
1547                 {
1548                         ShowPanelDetail(false);
1549                 }
1550                 break;
1551         }
1552         case ACTION_ID_DELETE_POPUP_CANCEL:
1553         {
1554                 __pDeletePopup->SetShowState(false);
1555                 __pDeletePopup->Show();
1556                 break;
1557         }
1558         case ACTION_ID_CONTORL_BUTTON_PLAY:
1559                 CallVideoPlayer();
1560                 break;
1561         default:
1562                 break;
1563         }
1564         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1565 }
1566
1567 void
1568 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1569 {
1570         result r = E_SUCCESS;
1571         ImageBuffer* pRotatedBuffer = null;
1572         ImageBuffer* pRotatedBuffer1 = null;
1573         ImageFormat imageFormat;
1574         int width = 0;
1575         int height = 0;
1576         pRotatedBuffer = new (std::nothrow) ImageBuffer();
1577         r = pRotatedBuffer->Construct(filePath);
1578         pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1579         if (r == E_SUCCESS)
1580         {
1581                 if (rotateMode == ROTATE_MODE_RIGHT)
1582                 {
1583                         pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1584                 }
1585                 else
1586                 {
1587                         pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1588                 }
1589         }
1590         TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1591         pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1592         delete pRotatedBuffer1;
1593         delete pRotatedBuffer;
1594         return;
1595
1596         CATCH:
1597         if (pRotatedBuffer != null) //this buffer is no longer used
1598         {
1599                 delete pRotatedBuffer;
1600         }
1601         if (pRotatedBuffer1 != null) //this buffer is no longer used
1602         {
1603                 delete pRotatedBuffer1;
1604         }
1605         return;
1606 }
1607
1608 void
1609 ImageViewerForm::OnFormBackRequested(Form& source)
1610 {
1611         AppLogDebug("ENTER");
1612         if (__detail == false)
1613         {
1614                 ShowPanelDetail(false);
1615         }
1616         else
1617         {
1618                 UiApp* pApp = UiApp::GetInstance();
1619                 pApp->Terminate();
1620         }
1621         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1622 }
1623
1624 void
1625 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1626                 const SceneId& currentSceneId, IList* pArgs)
1627 {
1628         AppLogDebug("ENTER");
1629
1630         Rectangle clientRect = GetClientAreaBounds();
1631         Rectangle rect = GetBounds();
1632
1633         __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1634         __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height -  __pLabel->GetHeight()));
1635         __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1636
1637         if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1638         {
1639                 SetDetailInfo();
1640                 String strItemIdxText(EMPTY_SPACE);
1641                 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1642                 __pLabel->SetText(strItemIdxText);
1643                 Invalidate(true);
1644         }
1645
1646         if (__pGallery->GetCurrentItemIndex() < 0)
1647         {
1648                 SetFooterItemState(false);
1649         }
1650         else
1651         {
1652                 SetFooterItemState(true);
1653         }
1654         Invalidate(true);
1655         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1656 }
1657
1658 void
1659 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1660                 const SceneId& nextSceneId)
1661 {
1662         AppLogDebug("ENTER");
1663         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1664 }
1665
1666 void
1667 ImageViewerForm::OnImageDecodedN(const int index)
1668 {
1669         AppLogDebug("ENTER");
1670         __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1671         __pGallery->Draw();
1672         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1673 }
1674
1675 void
1676 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1677                 const String& operationId, AppCtrlResult appControlResult,
1678                 const IMap* pExtraData)
1679 {
1680         AppLogDebug("ENTER");
1681
1682         if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1683                         && operationId == APPCONTROL_OPERATION_ID_PICK
1684                         && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1685         {
1686                 const String* pContactId =
1687                                 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1688                 SceneManager* pSceneManager = SceneManager::GetInstance();
1689                 long long lresult = 0;
1690                 if (pContactId != null && pContactId->GetLength() > 0)
1691                 {
1692                         LongLong::Parse(*pContactId, lresult);
1693                 }
1694                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1695                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1696                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1697                 pList->Add(new (std::nothrow) LongLong(lresult));
1698                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1699                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1700         }
1701
1702         ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1703         pImageViewerApp->SetFrameEnabled(true);
1704         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1705 }
1706
1707 void
1708 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1709 {
1710         AppLogDebug("ENTER");
1711         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1712 }
1713
1714 void
1715 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1716 {
1717         AppLogDebug("ENTER");
1718         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1719 }
1720
1721 void
1722 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1723 {
1724         AppLogDebug("ENTER");
1725         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1726 }
1727
1728 void
1729 ImageViewerForm::OnOtherControlSelected(const Control& source)
1730 {
1731         AppLogDebug("ENTER");
1732         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1733 }
1734
1735 void
1736 ImageViewerForm::InitShowGallery(void)
1737 {
1738         AppLogDebug("ENTER");
1739         if (__pGallery != null && __pGallery->IsVisible() == false)
1740         {
1741                 Canvas* pCanvas = GetCanvasN();
1742                 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1743                 {
1744                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1745
1746                         return;
1747                 }
1748
1749                 pCanvas->Clear();
1750                 __pGallery->SetShowState(true);
1751                 delete pCanvas;
1752         }
1753         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1754 }
1755
1756 void
1757 ImageViewerForm::OnTimerExpired(Timer &timer)
1758 {
1759         AppLog("ImageViewerForm::OnTimerExpired");
1760
1761         if(timer.Equals(*__pShuffelTimer) == true)
1762         {
1763                 AppLog("OnTimerExpired __pShuffelTimer");
1764                 int curItemIndex = __pGallery->GetCurrentItemIndex();
1765                 int index = __pShuffledList[curItemIndex];
1766
1767                 __shuffle = false;
1768
1769                 __pGallery->UpdateGallery();
1770
1771                 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1772
1773                 __pGallery->SetCurrentItemIndex(index);
1774                 __pGallery->Draw();
1775
1776                 SlideShowStopped(index);
1777                 return;
1778         }
1779
1780         int repeatValue  = 0;
1781         int shuffleValue = 0;
1782
1783         if (__pPresentationModel->GetFileCount() > 1)
1784         {
1785                 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1786                                                         ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1787
1788                  __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1789                                                         ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1790
1791                 
1792                 if(shuffleValue != 0)
1793                 {
1794                         __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1795                         CreateShuffledList(__pPresentationModel->GetFileCount());
1796                         __shuffle = true;
1797                 }
1798                 else
1799                 {
1800                         __shuffelStartIndex = 0;
1801                         __shuffle = false;
1802                 }
1803
1804                 if( repeatValue == 0)
1805                 {
1806                         __pGallery->StartSlideShow(false);
1807                 }
1808                 else
1809                 {
1810                         __pGallery->StartSlideShow(true);
1811                 }
1812         }
1813         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1814 }
1815
1816 void
1817 ImageViewerForm::CreateShuffledList(int count)
1818 {
1819         AppLogDebug("ImageViewerForm::CreateShuffledList ENTER");
1820         if(__pShuffledList == null)
1821         {
1822                 __pShuffledList = new (std::nothrow) int[count];
1823                 for(int i = 0; i < count; i++)
1824                 {
1825                         __pShuffledList[i] = i;
1826                 }
1827         }
1828         for(int i = count - 1; i > 1; i--)
1829         {
1830                 int randomNum = Math::Rand() % (i+1);
1831                 int t = __pShuffledList[randomNum];
1832                 __pShuffledList[randomNum] = __pShuffledList[i];
1833                 __pShuffledList[i] = t;
1834         }
1835
1836         for(int i = 0; i < count; i++)
1837         {
1838                 AppLogDebug("ShuffeldList i = %d & Val = %d", i, __pShuffledList[i]);
1839         }
1840
1841         AppLogDebug("ImageViewerForm::CreateShuffledList EXIT");
1842 }
1843
1844 void
1845 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1846 {
1847         AppLogDebug("ENTER");
1848         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1849 }
1850
1851 void
1852 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1853                 const String& errorMessage)
1854 {
1855         AppLogDebug("ENTER");
1856         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1857 }
1858
1859 void
1860 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1861                 result transferResult, const String& errorCode, const String& errorMessage)
1862 {
1863         AppLogDebug("ENTER");
1864         AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1865         AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1866         AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1867         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1868 }
1869
1870 void
1871 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1872                 const String& errorCode, const String& errorMessage)
1873 {
1874         AppLogDebug("ENTER");
1875         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1876 }
1877
1878 void
1879 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1880                 const String& errorMessage)
1881 {
1882         AppLogDebug("ENTER");
1883         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1884 }
1885
1886 void
1887 ImageViewerForm::RequestDecodeUrl(void)
1888 {
1889         AppLogDebug("ENTER");
1890
1891         String filePath = __pPresentationModel->GetFilePathAt(0);
1892
1893         if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1894         {
1895                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1896
1897                 return;
1898         }
1899
1900         __downLordFileName = __pPresentationModel->GetFileName(filePath);
1901
1902         Image* pImage = new (std::nothrow) Image();
1903         pImage->Construct();
1904         Uri uri;
1905         RequestId reqId;
1906         uri.SetUri(filePath);
1907
1908         pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1909
1910         delete pImage;
1911         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1912 }
1913
1914 void
1915 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1916                 result r, const String errorCode, const String errorMessage)
1917 {
1918         AppLogDebug("ENTER");
1919         Image* pImage = new (std::nothrow) Image();
1920         pImage->Construct();
1921
1922         String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1923         r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1924
1925         if (r == E_SUCCESS)
1926         {
1927                 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1928                 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1929
1930                 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1931                 __pGallery->Draw();
1932                 __pPresentationModel->RequestImage(destPath);
1933         }
1934         else
1935         {
1936                 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1937         }
1938
1939         delete pImage;
1940         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1941 }
1942
1943 void
1944 ImageViewerForm::OnRequestEmailAction(void)
1945 {
1946         AppLogDebug("ENTER");
1947         int currentIndex = __pGallery->GetCurrentItemIndex();
1948
1949         if (__pPresentationModel->GetFileCount() <= 0)
1950         {
1951                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1952                 return;
1953         }
1954
1955         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1956
1957         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1958         pDataList->Construct();
1959
1960         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1961         pList->Add(new (std::nothrow) String(filePath));
1962
1963         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1964
1965         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1966                         new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
1967         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1968 }
1969
1970 void
1971 ImageViewerForm::OnRequestMessagesAction(void)
1972 {
1973         AppLogDebug("ENTER");
1974         int currentIndex = __pGallery->GetCurrentItemIndex();
1975
1976         if (__pPresentationModel->GetFileCount() <= 0)
1977         {
1978                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1979                 return;
1980         }
1981
1982         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1983
1984         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1985         pDataList->Construct();
1986         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1987         pList->Add(new (std::nothrow) String(filePath));
1988         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1989
1990         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE,
1991                         new (std::nothrow) String(APPCONTROL_URI_MMS_TO), null, pDataList, this);
1992         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1993 }
1994
1995 void
1996 ImageViewerForm::SetFooterItemState(bool isEnable)
1997 {
1998         AppLogDebug("ENTER");
1999         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2000         {
2001                 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2002                 __pFooter->SetItemEnabled(0, isEnable);
2003                 __pFooter->SetItemEnabled(1, isEnable);
2004         }
2005         else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2006         {
2007                 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2008                 __pFooter->SetItemEnabled(0, isEnable);
2009                 __pFooter->SetItemEnabled(1, isEnable);
2010         }
2011         else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2012         {
2013                 __pFooter->SetItemEnabled(0, isEnable);
2014         }
2015         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2016 }
2017
2018 Bitmap*
2019 ImageViewerForm::GetQuickThumbnailN(String& filePath)
2020 {
2021         AppLogDebug("ENTER");
2022         Bitmap* pBitmap = null;
2023
2024         if (filePath.GetLength() > 4)
2025         {
2026                 int totalPage = 0;
2027                 int totalCount = 0;
2028                 ContentSearch contentSearch;
2029                 ContentSearchResult* pResultItem = null;
2030                 IList* pContentInfoList = null;
2031                 String queryString;
2032                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2033                 result r = contentSearch.Construct(contentType);
2034                 AppLogDebug("r(%s)", GetErrorMessage(r));
2035                 if (r != E_SUCCESS)
2036                 {
2037                         pBitmap = new (std::nothrow) Bitmap();
2038                         r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2039                         if (r == E_SUCCESS)
2040                         {
2041                                 return pBitmap;
2042                         }
2043                         else
2044                         {
2045                                 delete pBitmap;
2046                                 return null;
2047                         }
2048                 }
2049                 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2050                 queryString.Append(L"'");
2051                 queryString.Append(__pPresentationModel->GetFileName(filePath));
2052                 queryString.Append(L"'");
2053
2054                 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2055                                 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2056
2057                 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2058                 {
2059                         IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2060                         while (pEnum->MoveNext() == E_SUCCESS)
2061                         {
2062                                 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2063                                 if (pResultItem == null)
2064                                 {
2065                                         continue;
2066                                 }
2067
2068                                 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2069                                 {
2070                                         pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2071                                 }
2072                         }
2073                         delete pEnum;
2074                 }
2075
2076                 if (pContentInfoList != null)
2077                 {
2078                         delete pContentInfoList;
2079                 }
2080
2081                 if (pBitmap != null)
2082                 {
2083                         ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2084
2085                         if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2086                         {
2087                                 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2088                                 result r = imageBuffer->Construct(filePath);
2089                                 if (r == E_SUCCESS)
2090                                 {
2091                                         if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2092                                                         || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2093                                         {
2094                                                 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2095                                                 pBitmap->Scale(srcDim);
2096                                         }
2097                                         else
2098                                         {
2099                                                 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2100                                                 pBitmap->Scale(srcDim);
2101                                         }
2102
2103                                         delete imageBuffer;
2104                                 }
2105                         }
2106                         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2107                         {
2108                                 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2109
2110                                 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2111                                 {
2112                                         Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2113                                         pBitmap->Scale(srcDim);
2114                                         delete pVideoMeta;
2115                                 }
2116                         }
2117                 }
2118                 else
2119                 {
2120                         Canvas mainCanvas;
2121                         mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2122                         mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2123                         pBitmap = new (std::nothrow) Bitmap();
2124                         pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2125                 }
2126         }
2127         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2128         return pBitmap;
2129 }
2130
2131 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2132 {
2133         AppLogDebug(" ENTER");
2134         bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2135         bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2136
2137         int currentIndex = __pGallery->GetCurrentItemIndex();
2138         int countPath = __pPresentationModel->GetFileCount();
2139
2140         if (countPath == 0 && eventDelete)
2141         {
2142                 UiApp* pApp = UiApp::GetInstance();
2143                 pApp->Terminate();
2144                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2145         }
2146         AppLogDebug(" countPath is %d", countPath);
2147         AppLogDebug(" currentIndex is %d", currentIndex);
2148
2149         if (countPath == currentIndex && eventDelete)
2150         {
2151                 __pGallery->SetCurrentItemIndex(--currentIndex);
2152         }
2153         else if (eventMove)
2154         {
2155                 currentIndex = index;
2156                 __pGallery->SetCurrentItemIndex(currentIndex);
2157         }
2158
2159         String strItemIdxText(EMPTY_SPACE);
2160
2161         __pGallery->UpdateGallery();
2162         AppLogDebug(" UpdateGallery is %d", currentIndex);
2163         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2164         __pPresentationModel->RequestImage(filePath);
2165
2166         GetLabelText(currentIndex,strItemIdxText);
2167         __pLabel->SetText(strItemIdxText);
2168
2169         if (__visible == true)
2170         {
2171                 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2172
2173                 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2174                 {
2175                         __pPlayButton->SetShowState(false);
2176                 }
2177                 else
2178                 {
2179                         __pPlayButton->SetShowState(true);
2180                 }
2181         }
2182         if (__detail == false)
2183         {
2184                 __pScrollPanel->SetShowState(false);
2185                 __detail = true;
2186         }
2187
2188         Invalidate(true);
2189         AppLogDebug("EXIT");
2190 }
2191
2192 void
2193 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2194 {
2195         if ( __pPopUp != NULL)
2196         {
2197                 __pPopUp->SetShowState(false);
2198         }
2199
2200         if (index == 0)   // start slide show
2201         {
2202                 int repeatValue = 0;
2203
2204                 if (__pPresentationModel->GetFileCount() > 1)
2205                 {
2206                         int shuffleValue;
2207
2208                         __pGallery->UpdateGallery();
2209
2210                         if (__detail == false)
2211                         {
2212                                 ShowPanelDetail(false);
2213                         }
2214
2215                         __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2216                                         ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2217
2218                         __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2219                                         ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2220
2221                         if (shuffleValue != 0)
2222                         {
2223                                 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2224                                 CreateShuffledList(__pPresentationModel->GetFileCount());
2225                                 __shuffle = true;
2226                         }
2227                         else
2228                         {
2229                                 __shuffelStartIndex = 0;
2230                                 __shuffle = false;
2231                         }
2232
2233                         if (repeatValue == 0)
2234                         {
2235                                 __pGallery->StartSlideShow(false);
2236                         }
2237                         else
2238                         {
2239                                 __pGallery->StartSlideShow(true);
2240                         }
2241                 }
2242         }
2243         else if (index == 1) // launch settings
2244         {
2245                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2246                                 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);
2247         }
2248 }