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