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