Fix for message
[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(ResourceManager::GetString(L"IDS_IV_POP_SET_WALLPAPER_FOR_HOME_SCREEN_AND_LOCK_SCREEN"),
813                         ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
814         __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
815                         ACTION_ID_CONTEXTMENU_CALLER);
816         __pContextMenuSetAs->AddActionEventListener(*this);
817         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
818
819         return E_SUCCESS;
820 }
821
822 result
823 ImageViewerForm::InitializeContextMenuShare(void)
824 {
825         AppLogDebug("ENTER");
826         if (__pContextMenuShare != null)
827         {
828                 delete __pContextMenuShare;
829                 __pContextMenuShare = null;
830         }
831         __pContextMenuShare = new (std::nothrow) ContextMenu();
832         __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
833                         GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
834                         CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
835
836         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
837                         ACTION_ID_CONTEXTMENU_MESSAGE);
838         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
839         __pContextMenuShare->AddActionEventListener(*this);
840         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
841
842         return E_SUCCESS;
843 }
844
845 long long
846 ImageViewerForm::GetFileSize(String filePath)
847 {
848         AppLogDebug("ENTER");
849         FileAttributes attr;
850         long long size = 0;
851
852         result r = File::GetAttributes(filePath, attr);
853         if (r != E_SUCCESS)
854         {
855                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
856
857                 return 0;
858         }
859         size = attr.GetFileSize();
860         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
861
862         return size;
863 }
864
865 result
866 ImageViewerForm::SetDetailInfo(void)
867 {
868         AppLogDebug("ENTER");
869
870         Rectangle clientRect = GetClientAreaBounds();
871         __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
872
873         int currentIndex = __pGallery->GetCurrentItemIndex();
874         String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
875
876         ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
877
878         String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
879
880         strResult[0] = __pPresentationModel->GetFileName(strFilePath);
881         strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
882
883         FileAttributes attr;
884         result r = File::GetAttributes(strFilePath, attr);
885         if (r == E_SUCCESS)
886         {
887                 long long nSize = attr.GetFileSize();
888                 DateTime dateTime = attr.GetDateTime();
889                 strResult[2] = dateTime.ToString();
890
891                 if (nSize > SINGLE_GIGA_BYTE)
892                 {
893                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
894                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
895                 }
896                 else if (nSize > SINGLE_MEGA_BYTE)
897                 {
898                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
899                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
900                 }
901                 else if (nSize > SINGLE_KILO_BYTE)
902                 {
903                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
904                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
905                 }
906                 else
907                 {
908                         strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
909                         strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
910                 }
911         }
912         else
913         {
914                 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
915                 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
916         }
917
918         strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919         strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
920         strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
921         strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
922         strResult[8] = strFilePath;
923         String fileName = File::GetFileName(strFilePath);
924         strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
925
926         if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
927         {
928                 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
929         }
930
931         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
932         {
933                 strResult[0] = __downLordFileName;
934         }
935         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
936         {
937                 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
938
939                 if (pImgMeta != null)
940                 {
941                         ImageContentInfo imageContentInfo;
942                         r = imageContentInfo.Construct(&strFilePath);
943                         if (r == E_SUCCESS)
944                         {
945                                 strResult[1] = imageContentInfo.GetMediaFormat();
946                                 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
947                                                 pImgMeta->GetHeight());
948
949                                 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
950                                 {
951                                         strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
952                                 }
953
954                                 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
955                                 {
956                                         strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
957                                         strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
958                                 }
959                         }
960                         delete pImgMeta;
961                 }
962         }
963         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
964         {
965                 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
966                 if (pVideoMeta != null)
967                 {
968                         VideoContentInfo videoContentInfo;
969                         r = videoContentInfo.Construct(&strFilePath);
970                         if (r == E_SUCCESS)
971                         {
972                                 strResult[1] = videoContentInfo.GetMediaFormat();
973                                 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
974                                                 pVideoMeta->GetHeight());
975                                 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
976                                 {
977                                         strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
978                                 }
979                         }
980                 }
981         }
982
983         for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
984         {
985                 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
986                 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
987         }
988
989         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
990         {
991                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
992                 return r;
993         }
994
995         Rectangle rect = GetBounds();
996         __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
997
998         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
999
1000         return r;
1001 }
1002
1003 result
1004 ImageViewerForm::ShowPanelDetail(bool showStatus)
1005 {
1006         AppLogDebug("ENTER");
1007         if (showStatus)
1008         {
1009                 SetDetailInfo();
1010                 __pScrollPanel->SetShowState(true);
1011                 __detail = false;
1012         }
1013         else
1014         {
1015                 __pScrollPanel->SetShowState(false);
1016                 __detail = true;
1017         }
1018         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1019
1020         return E_SUCCESS;
1021 }
1022
1023 result
1024 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1025 {
1026         AppLogDebug("ENTER");
1027         FooterItem footerItem;
1028         footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1029         Bitmap* pfooterItem = null;
1030
1031         if (isChanged)
1032         {
1033                 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1034                 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1035         }
1036         else
1037         {
1038                 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1039                 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1040         }
1041
1042         pFooter->SetItemAt(position, footerItem);
1043         pFooter->Invalidate(true);
1044
1045         delete pfooterItem;
1046         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1047
1048         return E_SUCCESS;
1049 }
1050
1051 void
1052 ImageViewerForm::DownloadFile(void)
1053 {
1054         AppLogDebug("ENTER");
1055         String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1056         if (File::IsFileExist(DestPath) == false)
1057         {
1058                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1059                 return;
1060         }
1061
1062         ContentId contentId;
1063         ContentManager contentManager;
1064         contentManager.Construct();
1065
1066         ImageContentInfo imageContentInfo;
1067         imageContentInfo.Construct(null);
1068
1069         imageContentInfo.SetKeyword(L"platform, tizen");
1070         String sourcePath = DestPath;
1071         String destPath = Environment::GetMediaPath();
1072         destPath.Append(FOLDER_PATH_DOWNLOADS);
1073         destPath.Append(__downLordFileName);
1074
1075         contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1076         ImageViewerForm::OnFormBackRequested(*this);
1077         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1078 }
1079
1080 int
1081 ImageViewerForm::GetItemCount(void)
1082 {
1083         AppLogDebug("ENTER");
1084         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1085
1086         return __pPresentationModel->GetFileCount();
1087 }
1088
1089 GalleryItem*
1090 ImageViewerForm::CreateItem(int index)
1091 {
1092         AppLogDebug("ENTER : index(%d)", index);
1093         GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1094
1095         int curIndex = index;
1096
1097         if(__shuffle == true && __pShuffledList != null)
1098         {
1099                 curIndex = __pShuffledList[index];
1100         }
1101
1102         String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1103         ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1104         Bitmap* pBitmap = pImageInfo->GetBitmapN();
1105
1106         if (pBitmap == null)
1107         {
1108                 pBitmap = GetQuickThumbnailN(filePath);
1109
1110                 if (pBitmap == null)
1111                 {
1112                         pBitmap = new (std::nothrow) Bitmap();
1113                         pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1114                 }
1115         }
1116         pGallery->Construct(*pBitmap, filePath);
1117         delete pBitmap;
1118         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1119
1120         return pGallery;
1121 }
1122
1123 bool
1124 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1125 {
1126         AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1127         int curIndex = index;
1128
1129         if(__shuffle == true && __pShuffledList != null)
1130         {
1131                 curIndex = __pShuffledList[index];
1132         }
1133
1134
1135         ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1136         pImageInfo->ClearBitmap();
1137         delete pItem;
1138         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1139
1140         return true;
1141 }
1142
1143 void
1144 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1145 {
1146         AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1147
1148         String filePath = __pPresentationModel->GetFilePathAt(index);
1149         AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1150         __pPresentationModel->RequestImage(filePath);
1151
1152         String strItemIdxText;
1153         GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1154         __pLabel->SetText(strItemIdxText);
1155
1156         if (__visible == true)
1157         {
1158                 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1159                 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1160                 {
1161                         __pPlayButton->SetShowState(true);
1162                 }
1163                 else
1164                 {
1165                         __pPlayButton->SetShowState(false);
1166                 }
1167         }
1168
1169         Invalidate(true);
1170         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1171 }
1172
1173 void
1174 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1175 {
1176         AppLogDebug("ENTER");
1177
1178         String filePath = __pPresentationModel->GetFilePathAt(index);
1179         ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1180
1181         if (__visible == true)
1182         {
1183                 if (contentType == CONTENT_TYPE_VIDEO)
1184                 {
1185                         __pPlayButton->SetShowState(false);
1186                 }
1187
1188                 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1189                 __pLabel->SetShowState(false);
1190                 __visible = false;
1191         }
1192         else
1193         {
1194                 if (contentType == CONTENT_TYPE_VIDEO)
1195                 {
1196                         __pPlayButton->SetShowState(true);
1197                 }
1198
1199                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1200                 __pLabel->SetShowState(true);
1201                 __visible = true;
1202
1203                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1204                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1205         }
1206
1207         Rectangle clientRect = GetClientAreaBounds();
1208         Rectangle rect = GetBounds();
1209         __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1210         Invalidate(true);
1211         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1212 }
1213
1214 void
1215 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1216 {
1217         AppLogDebug("ENTER");
1218         PowerManager::KeepScreenOnState(true, false);
1219         if (__visible  == true)
1220         {
1221                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1222                 __pLabel->SetShowState(false);
1223
1224                 int index = __pGallery->GetCurrentItemIndex();
1225                 String filePath = __pPresentationModel->GetFilePathAt(index);
1226                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1227
1228                 if (contentType == CONTENT_TYPE_VIDEO)
1229                 {
1230                         __pPlayButton->SetShowState(false);
1231                 }
1232
1233                 __visible = false;
1234         }
1235
1236         Rectangle clientRect = GetClientAreaBounds();
1237         Rectangle rect = GetBounds();
1238         __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1239         Invalidate(true);
1240         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1241 }
1242
1243 void
1244 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1245 {
1246         AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1247
1248         int index;
1249
1250         if(__shuffle == true)
1251         {
1252
1253                 if(__pShuffelTimer == null)
1254                 {
1255                         __pShuffelTimer = new (std::nothrow) Timer();
1256                         __pShuffelTimer->Construct(*this);
1257                 }
1258                 __pShuffelTimer->Start(1);
1259         }
1260         else
1261         {
1262                 index = __pGallery->GetCurrentItemIndex();
1263                 SlideShowStopped(index);
1264         }
1265
1266
1267         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1268 }
1269
1270 void
1271 ImageViewerForm::SlideShowStopped(int index)
1272 {
1273         AppLog("ImageViewerForm::SlideShowStopped");
1274         PowerManager::KeepScreenOnState(false, true);
1275
1276         if (__visible == false)
1277         {
1278                 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1279                 __pLabel->SetShowState(true);
1280                 String filePath = __pPresentationModel->GetFilePathAt(index);
1281                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1282                 if (contentType == CONTENT_TYPE_VIDEO)
1283                 {
1284                         __pPlayButton->SetShowState(true);
1285                 }
1286
1287                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1288                 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1289
1290                 __visible = true;
1291         }
1292
1293         String strItemIdxText;
1294         GetLabelText(index, strItemIdxText);
1295         __pLabel->SetText(strItemIdxText);
1296
1297
1298         Rectangle clientRect = GetClientAreaBounds();
1299         Rectangle rect = GetBounds();
1300         __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1301
1302         Invalidate(true);
1303 }
1304
1305 void
1306 ImageViewerForm::OnUpdateContentList(void)
1307 {
1308 }
1309
1310 result
1311 ImageViewerForm::OnTerminating(void)
1312 {
1313         AppLogDebug("ENTER");
1314
1315         if (__pTimer != null)
1316         {
1317                 __pTimer->Cancel();
1318                 delete __pTimer;
1319                 __pTimer = null;
1320         }
1321
1322         if(__pShuffelTimer)
1323         {
1324                 __pShuffelTimer->Cancel();
1325                 delete __pShuffelTimer;
1326                 __pShuffelTimer = null;
1327         }
1328
1329         __pPresentationModel->ClearImageRequests();
1330         __pPresentationModel->RemoveListener(*this);
1331         __pPresentationModel->RemoveFileUpdateListener(*this);
1332
1333         if (__pContextMenuCopy != null)
1334         {
1335                 delete __pContextMenuCopy;
1336                 __pContextMenuCopy = null;
1337         }
1338
1339         if (__pContextMenuSetAs != null)
1340         {
1341                 delete __pContextMenuSetAs;
1342                 __pContextMenuSetAs = null;
1343         }
1344
1345         if (__pDeletePopup != null)
1346         {
1347                 delete __pDeletePopup;
1348                 __pDeletePopup = null;
1349         }
1350
1351         if (__pContextMenuShare != null)
1352         {
1353                 delete __pContextMenuShare;
1354                 __pContextMenuShare = null;
1355         }
1356
1357         if (__pContextMenuMore != null)
1358         {
1359                 delete __pContextMenuMore;
1360                 __pContextMenuMore = null;
1361         }
1362
1363         if(__pShuffledList != null)
1364         {
1365                 free(__pShuffledList);
1366                 __pShuffledList = null;
1367         }
1368
1369         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1370
1371         return E_SUCCESS;
1372 }
1373
1374 void
1375 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1376 {
1377         AppLogDebug("ENTER actionId(%d)", actionId);
1378         SceneManager* pSceneManager = SceneManager::GetInstance();
1379         InitShowGallery();
1380
1381         switch (actionId)
1382         {
1383         case ACTION_ID_FOOTER_MORE:
1384         {
1385                 InitializeContextMenuMore();
1386
1387                 __pContextMenuMore->SetShowState(true);
1388                 __pContextMenuMore->Show();
1389         }
1390         break;
1391         case ACTION_ID_CONTEXTMENU_SET_AS:
1392                 InitializeContextMenuSetAs();
1393
1394                 __pContextMenuSetAs->SetShowState(true);
1395                 __pContextMenuSetAs->Show();
1396                 break;
1397         case ACTION_ID_FOOTER_BUTTON_SHARE:
1398                 InitializeContextMenuShare();
1399
1400                 __pContextMenuShare->SetShowState(true);
1401                 __pContextMenuShare->Show();
1402                 break;
1403         case ACTION_ID_FOOTER_BUTTON_DELETE:
1404                 __pDeletePopup->SetShowState(true);
1405                 __pDeletePopup->Show();
1406                 break;
1407         case ACTION_ID_FOOTER_BUTTON_SLIDE:
1408         {
1409                 if (__pPopUp != null)
1410                 {
1411                         __pPopUp->SetShowState(true);
1412                         __pPopUp->Show();
1413                 }
1414
1415                 break;
1416         }
1417         case ACTION_ID_FOOTER_BUTTON_CROP:
1418         {
1419                 String filePath;
1420                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1421                 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1422                 pList->Add(new (std::nothrow) String(filePath));
1423                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1424         }
1425         break;
1426         case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1427         {
1428                 int currentIndex = __pGallery->GetCurrentItemIndex();
1429                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1430                 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1431                 __pPresentationModel->SetImageRotateStatus(true);
1432                 RotateImage(filePath, rotateMode);
1433                 __pPresentationModel->RequestImage(filePath);
1434                 //Invalidate(true);
1435                 ContentManager::ScanFile(filePath);
1436         }
1437         break;
1438         case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1439         {
1440                 int currentIndex = __pGallery->GetCurrentItemIndex();
1441                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1442                 RotateMode rotateMode = ROTATE_MODE_LEFT;
1443                 __pPresentationModel->SetImageRotateStatus(true);
1444                 RotateImage(filePath, rotateMode);
1445                 __pPresentationModel->RequestImage(filePath);
1446                 //Invalidate(true);
1447                 ContentManager::ScanFile(filePath);
1448         }
1449         break;
1450         case ACTION_ID_FOOTER_BUTTON_DETAILS:
1451         {
1452                 ShowPanelDetail(__detail);
1453                 break;
1454         }
1455         case ACTION_ID_FOOTER_BUTTON_BACK:
1456                 ImageViewerForm::OnFormBackRequested(*this);
1457                 break;
1458         case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1459                 DownloadFile();
1460                 break;
1461         case ACTION_ID_FOOTER_BUTTON_SAVE:
1462                 break;
1463         case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1464         {
1465                 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1466                 pSelectedIndex->Construct();
1467                 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1468                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1469                 break;
1470         }
1471         case ACTION_ID_CONTEXTMENU_HOME:
1472         {
1473                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1474                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1475                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1476                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1477                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1478                 break;
1479         }
1480         case ACTION_ID_CONTEXTMENU_LOCK:
1481         {
1482                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1483                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1484                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1485                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1486                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1487                 break;
1488         }
1489         case ACTION_ID_CONTEXTMENU_CALLER:
1490         {
1491                 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1492                 pDataList->Construct();
1493                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1494                                 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1495                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1496                                 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1497                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1498                                 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1499
1500                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1501                                 APPCONTROL_OPERATION_ID_SOCIAL_PICK, null, null, pDataList, this);
1502                 break;
1503         }
1504
1505         case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1506         {
1507                 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1508                 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1509                 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1510                 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1511                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1512                 break;
1513                 break;
1514         }
1515
1516         case ACTION_ID_CONTEXTMENU_EMAIL:
1517         {
1518                 OnRequestEmailAction();
1519                 break;
1520         }
1521         case ACTION_ID_CONTEXTMENU_MESSAGE:
1522         {
1523                 OnRequestMessagesAction();
1524                 break;
1525         }
1526         case ACTION_ID_CONTEXTMENU_COPY:
1527         {
1528                 int currentIndex = __pGallery->GetCurrentItemIndex();
1529                 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1530
1531                 ClipboardItem item;
1532                 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1533                 Clipboard* pClipboard = Clipboard::GetInstance();
1534                 pClipboard->CopyItem(item);
1535                 break;
1536         }
1537         case ACTION_ID_DELETE_POPUP_DEL:
1538         {
1539                 __pDeletePopup->SetShowState(false);
1540                 __pDeletePopup->Show();
1541                 DeleteImageFile();
1542
1543                 if (__detail == false)
1544                 {
1545                         ShowPanelDetail(false);
1546                 }
1547                 break;
1548         }
1549         case ACTION_ID_DELETE_POPUP_CANCEL:
1550         {
1551                 __pDeletePopup->SetShowState(false);
1552                 __pDeletePopup->Show();
1553                 break;
1554         }
1555         case ACTION_ID_CONTORL_BUTTON_PLAY:
1556                 CallVideoPlayer();
1557                 break;
1558         default:
1559                 break;
1560         }
1561         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1562 }
1563
1564 void
1565 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1566 {
1567         result r = E_SUCCESS;
1568         ImageBuffer* pRotatedBuffer = null;
1569         ImageBuffer* pRotatedBuffer1 = null;
1570         ImageFormat imageFormat;
1571         int width = 0;
1572         int height = 0;
1573         pRotatedBuffer = new (std::nothrow) ImageBuffer();
1574         r = pRotatedBuffer->Construct(filePath);
1575         pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1576         if (r == E_SUCCESS)
1577         {
1578                 if (rotateMode == ROTATE_MODE_RIGHT)
1579                 {
1580                         pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1581                 }
1582                 else
1583                 {
1584                         pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1585                 }
1586         }
1587         TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1588         pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1589         delete pRotatedBuffer1;
1590         delete pRotatedBuffer;
1591         return;
1592
1593         CATCH:
1594         if (pRotatedBuffer != null) //this buffer is no longer used
1595         {
1596                 delete pRotatedBuffer;
1597         }
1598         if (pRotatedBuffer1 != null) //this buffer is no longer used
1599         {
1600                 delete pRotatedBuffer1;
1601         }
1602         return;
1603 }
1604
1605 void
1606 ImageViewerForm::OnFormBackRequested(Form& source)
1607 {
1608         AppLogDebug("ENTER");
1609         if (__detail == false)
1610         {
1611                 ShowPanelDetail(false);
1612         }
1613         else
1614         {
1615                 UiApp* pApp = UiApp::GetInstance();
1616                 pApp->Terminate();
1617         }
1618         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1619 }
1620
1621 void
1622 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1623                 const SceneId& currentSceneId, IList* pArgs)
1624 {
1625         AppLogDebug("ENTER");
1626
1627         Rectangle clientRect = GetClientAreaBounds();
1628         Rectangle rect = GetBounds();
1629
1630         __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1631         __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height -  __pLabel->GetHeight()));
1632         __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1633
1634         if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1635         {
1636                 SetDetailInfo();
1637                 String strItemIdxText(EMPTY_SPACE);
1638                 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1639                 __pLabel->SetText(strItemIdxText);
1640                 Invalidate(true);
1641         }
1642
1643         if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
1644         {
1645                 AppLog("Manish hello");
1646                 String* pFilePath = null;
1647                 pFilePath = static_cast<String*>(pArgs->GetAt(0));
1648                 delete pArgs;
1649                 AppLog("Manish %ls", pFilePath->GetPointer());
1650                 String filePath;
1651                 filePath.Append(*pFilePath);
1652                 int count = __pPresentationModel->GetFileCount();
1653                 __pPresentationModel->SetImageCacheAt(count, filePath);
1654                 __pGallery->UpdateGallery();
1655                 __pGallery->SetCurrentItemIndex(count);
1656                 __pPresentationModel->RequestImage(filePath);
1657         }
1658
1659         if (__pGallery->GetCurrentItemIndex() < 0)
1660         {
1661                 SetFooterItemState(false);
1662         }
1663         else
1664         {
1665                 SetFooterItemState(true);
1666         }
1667         Invalidate(true);
1668         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1669 }
1670
1671 void
1672 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1673                 const SceneId& nextSceneId)
1674 {
1675         AppLogDebug("ENTER");
1676         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1677 }
1678
1679 void
1680 ImageViewerForm::OnImageDecodedN(const int index)
1681 {
1682         AppLogDebug("ENTER");
1683         __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1684         __pGallery->Draw();
1685         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1686 }
1687
1688 void
1689 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1690                 const String& operationId, AppCtrlResult appControlResult,
1691                 const IMap* pExtraData)
1692 {
1693         AppLogDebug("ENTER");
1694
1695         if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1696                         && operationId == APPCONTROL_OPERATION_ID_SOCIAL_PICK
1697                         && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1698         {
1699                 const ArrayList* pResultList =
1700                                 static_cast<const ArrayList*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1701                 const String* pContactId = null;
1702
1703                 if (pResultList != null)
1704                 {
1705                         pContactId = static_cast<const String*>(pResultList->GetAt(0));
1706                 }
1707
1708                 long long lresult = 0;
1709                 if (pContactId != null && pContactId->GetLength() > 0)
1710                 {
1711                         LongLong::Parse(*pContactId, lresult);
1712
1713                         ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1714                         pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1715                         pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1716                         pList->Add(new (std::nothrow) LongLong(lresult));
1717                         __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1718
1719                         SceneManager* pSceneManager = SceneManager::GetInstance();
1720                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1721                 }
1722         }
1723
1724         ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1725         pImageViewerApp->SetFrameEnabled(true);
1726         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1727 }
1728
1729 void
1730 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1731 {
1732         AppLogDebug("ENTER");
1733         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1734 }
1735
1736 void
1737 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1738 {
1739         AppLogDebug("ENTER");
1740         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1741 }
1742
1743 void
1744 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1745 {
1746         AppLogDebug("ENTER");
1747         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1748 }
1749
1750 void
1751 ImageViewerForm::OnOtherControlSelected(const Control& source)
1752 {
1753         AppLogDebug("ENTER");
1754         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1755 }
1756
1757 void
1758 ImageViewerForm::InitShowGallery(void)
1759 {
1760         AppLogDebug("ENTER");
1761         if (__pGallery != null && __pGallery->IsVisible() == false)
1762         {
1763                 Canvas* pCanvas = GetCanvasN();
1764                 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1765                 {
1766                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1767
1768                         return;
1769                 }
1770
1771                 pCanvas->Clear();
1772                 __pGallery->SetShowState(true);
1773                 delete pCanvas;
1774         }
1775         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1776 }
1777
1778 void
1779 ImageViewerForm::OnTimerExpired(Timer &timer)
1780 {
1781         AppLog("ImageViewerForm::OnTimerExpired");
1782
1783         if(timer.Equals(*__pShuffelTimer) == true)
1784         {
1785                 AppLog("OnTimerExpired __pShuffelTimer");
1786                 int curItemIndex = __pGallery->GetCurrentItemIndex();
1787                 int index = __pShuffledList[curItemIndex];
1788
1789                 __shuffle = false;
1790
1791                 __pGallery->UpdateGallery();
1792
1793                 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1794
1795                 __pGallery->SetCurrentItemIndex(index);
1796                 __pGallery->Draw();
1797
1798                 SlideShowStopped(index);
1799                 return;
1800         }
1801
1802         int repeatValue  = 0;
1803         int shuffleValue = 0;
1804
1805         if (__pPresentationModel->GetFileCount() > 1)
1806         {
1807                 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1808                                                         ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1809
1810                  __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1811                                                         ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1812
1813                 
1814                 if(shuffleValue != 0)
1815                 {
1816                         __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1817                         CreateShuffledList(__pPresentationModel->GetFileCount());
1818                         __shuffle = true;
1819                 }
1820                 else
1821                 {
1822                         __shuffelStartIndex = 0;
1823                         __shuffle = false;
1824                 }
1825
1826                 if( repeatValue == 0)
1827                 {
1828                         __pGallery->StartSlideShow(false);
1829                 }
1830                 else
1831                 {
1832                         __pGallery->StartSlideShow(true);
1833                 }
1834         }
1835         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1836 }
1837
1838 void
1839 ImageViewerForm::CreateShuffledList(int count)
1840 {
1841         AppLogDebug("ImageViewerForm::CreateShuffledList ENTER");
1842         if(__pShuffledList == null)
1843         {
1844                 __pShuffledList = new (std::nothrow) int[count];
1845                 for(int i = 0; i < count; i++)
1846                 {
1847                         __pShuffledList[i] = i;
1848                 }
1849         }
1850         for(int i = count - 1; i > 1; i--)
1851         {
1852                 int randomNum = Math::Rand() % (i+1);
1853                 int t = __pShuffledList[randomNum];
1854                 __pShuffledList[randomNum] = __pShuffledList[i];
1855                 __pShuffledList[i] = t;
1856         }
1857
1858         for(int i = 0; i < count; i++)
1859         {
1860                 AppLogDebug("ShuffeldList i = %d & Val = %d", i, __pShuffledList[i]);
1861         }
1862
1863         AppLogDebug("ImageViewerForm::CreateShuffledList EXIT");
1864 }
1865
1866 void
1867 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1868 {
1869         AppLogDebug("ENTER");
1870         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1871 }
1872
1873 void
1874 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1875                 const String& errorMessage)
1876 {
1877         AppLogDebug("ENTER");
1878         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1879 }
1880
1881 void
1882 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1883                 result transferResult, const String& errorCode, const String& errorMessage)
1884 {
1885         AppLogDebug("ENTER");
1886         AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1887         AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1888         AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1889         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1890 }
1891
1892 void
1893 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1894                 const String& errorCode, const String& errorMessage)
1895 {
1896         AppLogDebug("ENTER");
1897         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1898 }
1899
1900 void
1901 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1902                 const String& errorMessage)
1903 {
1904         AppLogDebug("ENTER");
1905         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1906 }
1907
1908 void
1909 ImageViewerForm::RequestDecodeUrl(void)
1910 {
1911         AppLogDebug("ENTER");
1912
1913         String filePath = __pPresentationModel->GetFilePathAt(0);
1914
1915         if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1916         {
1917                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1918
1919                 return;
1920         }
1921
1922         __downLordFileName = __pPresentationModel->GetFileName(filePath);
1923
1924         Image* pImage = new (std::nothrow) Image();
1925         pImage->Construct();
1926         Uri uri;
1927         RequestId reqId;
1928         uri.SetUri(filePath);
1929
1930         pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1931
1932         delete pImage;
1933         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1934 }
1935
1936 void
1937 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1938                 result r, const String errorCode, const String errorMessage)
1939 {
1940         AppLogDebug("ENTER");
1941         Image* pImage = new (std::nothrow) Image();
1942         pImage->Construct();
1943
1944         String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1945         r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1946
1947         if (r == E_SUCCESS)
1948         {
1949                 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1950                 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1951
1952                 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1953                 __pGallery->Draw();
1954                 __pPresentationModel->RequestImage(destPath);
1955         }
1956         else
1957         {
1958                 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1959         }
1960
1961         delete pImage;
1962         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1963 }
1964
1965 void
1966 ImageViewerForm::OnRequestEmailAction(void)
1967 {
1968         AppLogDebug("ENTER");
1969         int currentIndex = __pGallery->GetCurrentItemIndex();
1970
1971         if (__pPresentationModel->GetFileCount() <= 0)
1972         {
1973                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1974                 return;
1975         }
1976
1977         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1978
1979         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1980         pDataList->Construct();
1981
1982         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1983         pList->Add(new (std::nothrow) String(filePath));
1984
1985         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1986
1987         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1988                         new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
1989         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1990 }
1991
1992 void
1993 ImageViewerForm::OnRequestMessagesAction(void)
1994 {
1995         AppLogDebug("ENTER");
1996         int currentIndex = __pGallery->GetCurrentItemIndex();
1997
1998         if (__pPresentationModel->GetFileCount() <= 0)
1999         {
2000                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2001                 return;
2002         }
2003
2004         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2005
2006         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2007         pDataList->Construct();
2008         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2009         pList->Add(new (std::nothrow) String(filePath));
2010         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
2011         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
2012
2013         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE, null,
2014                         null, pDataList, this);
2015         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2016 }
2017
2018 void
2019 ImageViewerForm::SetFooterItemState(bool isEnable)
2020 {
2021         AppLogDebug("ENTER");
2022         if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2023         {
2024                 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2025                 __pFooter->SetItemEnabled(0, isEnable);
2026                 __pFooter->SetItemEnabled(1, isEnable);
2027         }
2028         else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2029         {
2030                 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2031                 __pFooter->SetItemEnabled(0, isEnable);
2032                 __pFooter->SetItemEnabled(1, isEnable);
2033         }
2034         else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2035         {
2036                 __pFooter->SetItemEnabled(0, isEnable);
2037         }
2038         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2039 }
2040
2041 Bitmap*
2042 ImageViewerForm::GetQuickThumbnailN(String& filePath)
2043 {
2044         AppLogDebug("ENTER");
2045         Bitmap* pBitmap = null;
2046
2047         if (filePath.GetLength() > 4)
2048         {
2049                 int totalPage = 0;
2050                 int totalCount = 0;
2051                 ContentSearch contentSearch;
2052                 ContentSearchResult* pResultItem = null;
2053                 IList* pContentInfoList = null;
2054                 String queryString;
2055                 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2056                 result r = contentSearch.Construct(contentType);
2057                 AppLogDebug("r(%s)", GetErrorMessage(r));
2058                 if (r != E_SUCCESS)
2059                 {
2060                         pBitmap = new (std::nothrow) Bitmap();
2061                         r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2062                         if (r == E_SUCCESS)
2063                         {
2064                                 return pBitmap;
2065                         }
2066                         else
2067                         {
2068                                 delete pBitmap;
2069                                 return null;
2070                         }
2071                 }
2072                 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2073                 queryString.Append(L"'");
2074                 queryString.Append(__pPresentationModel->GetFileName(filePath));
2075                 queryString.Append(L"'");
2076
2077                 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2078                                 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2079
2080                 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2081                 {
2082                         IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2083                         while (pEnum->MoveNext() == E_SUCCESS)
2084                         {
2085                                 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2086                                 if (pResultItem == null)
2087                                 {
2088                                         continue;
2089                                 }
2090
2091                                 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2092                                 {
2093                                         pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2094                                 }
2095                         }
2096                         delete pEnum;
2097                 }
2098
2099                 if (pContentInfoList != null)
2100                 {
2101                         delete pContentInfoList;
2102                 }
2103
2104                 if (pBitmap != null)
2105                 {
2106                         ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2107
2108                         if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2109                         {
2110                                 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2111                                 result r = imageBuffer->Construct(filePath);
2112                                 if (r == E_SUCCESS)
2113                                 {
2114                                         if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2115                                                         || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2116                                         {
2117                                                 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2118                                                 pBitmap->Scale(srcDim);
2119                                         }
2120                                         else
2121                                         {
2122                                                 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2123                                                 pBitmap->Scale(srcDim);
2124                                         }
2125
2126                                         delete imageBuffer;
2127                                 }
2128                         }
2129                         else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2130                         {
2131                                 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2132
2133                                 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2134                                 {
2135                                         Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2136                                         pBitmap->Scale(srcDim);
2137                                         delete pVideoMeta;
2138                                 }
2139                         }
2140                 }
2141                 else
2142                 {
2143                         Canvas mainCanvas;
2144                         mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2145                         mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2146                         pBitmap = new (std::nothrow) Bitmap();
2147                         pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2148                 }
2149         }
2150         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2151         return pBitmap;
2152 }
2153
2154 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2155 {
2156         AppLogDebug(" ENTER");
2157         bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2158         bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2159
2160         int currentIndex = __pGallery->GetCurrentItemIndex();
2161         int countPath = __pPresentationModel->GetFileCount();
2162
2163         if (countPath == 0 && eventDelete)
2164         {
2165                 UiApp* pApp = UiApp::GetInstance();
2166                 pApp->Terminate();
2167                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2168         }
2169         AppLogDebug(" countPath is %d", countPath);
2170         AppLogDebug(" currentIndex is %d", currentIndex);
2171
2172         if (countPath == currentIndex && eventDelete)
2173         {
2174                 __pGallery->SetCurrentItemIndex(--currentIndex);
2175         }
2176         else if (eventMove)
2177         {
2178                 currentIndex = index;
2179                 __pGallery->SetCurrentItemIndex(currentIndex);
2180         }
2181
2182         String strItemIdxText(EMPTY_SPACE);
2183
2184         __pGallery->UpdateGallery();
2185         AppLogDebug(" UpdateGallery is %d", currentIndex);
2186         String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2187         __pPresentationModel->RequestImage(filePath);
2188
2189         GetLabelText(currentIndex,strItemIdxText);
2190         __pLabel->SetText(strItemIdxText);
2191
2192         if (__visible == true)
2193         {
2194                 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2195
2196                 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2197                 {
2198                         __pPlayButton->SetShowState(false);
2199                 }
2200                 else
2201                 {
2202                         __pPlayButton->SetShowState(true);
2203                 }
2204         }
2205         if (__detail == false)
2206         {
2207                 __pScrollPanel->SetShowState(false);
2208                 __detail = true;
2209         }
2210
2211         Invalidate(true);
2212         AppLogDebug("EXIT");
2213 }
2214
2215 void
2216 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2217 {
2218         if ( __pPopUp != NULL)
2219         {
2220                 __pPopUp->SetShowState(false);
2221         }
2222
2223         if (index == 0)   // start slide show
2224         {
2225                 int repeatValue = 0;
2226
2227                 if (__pPresentationModel->GetFileCount() > 1)
2228                 {
2229                         int shuffleValue;
2230
2231                         __pGallery->UpdateGallery();
2232
2233                         if (__detail == false)
2234                         {
2235                                 ShowPanelDetail(false);
2236                         }
2237
2238                         __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2239                                         ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2240
2241                         __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2242                                         ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2243
2244                         if (shuffleValue != 0)
2245                         {
2246                                 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2247                                 CreateShuffledList(__pPresentationModel->GetFileCount());
2248                                 __shuffle = true;
2249                         }
2250                         else
2251                         {
2252                                 __shuffelStartIndex = 0;
2253                                 __shuffle = false;
2254                         }
2255
2256                         if (repeatValue == 0)
2257                         {
2258                                 __pGallery->StartSlideShow(false);
2259                         }
2260                         else
2261                         {
2262                                 __pGallery->StartSlideShow(true);
2263                         }
2264                 }
2265         }
2266         else if (index == 1) // launch settings
2267         {
2268                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2269                                 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);
2270         }
2271 }