3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.tizenopensource.org/license
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "AppResourceId.h"
19 #include "GeneratePanel.h"
21 #include "FileManagerForm.h"
22 #include <FSysEnvironment.h>
24 using namespace Tizen::Base;
25 using namespace Tizen::Graphics;
26 using namespace Tizen::Ui;
27 using namespace Tizen::Ui::Controls;
28 using namespace Tizen::Ui::Scenes;
31 GeneratePanel::GeneratePanel(void)
32 : __currentFeaturePath(Tizen::System::Environment::GetMediaPath() + "default.xdb")
33 , __currentImagePath(Tizen::System::Environment::GetMediaPath())
37 GeneratePanel::~GeneratePanel(void)
42 GeneratePanel::Initialize()
44 Panel::Construct(IDC_GENERATION_MODE_PANEL);
49 GeneratePanel::OnInitializing(void)
53 Button *pButton = null;
54 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
55 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(IDF_FORM, true));
57 Rectangle clienRect = pForm->GetClientAreaBounds();
58 this->SetBounds(clienRect);
60 pButton = static_cast<Button*>(GetControl(IDC_BUTTON_CHOOSE_IMAGE_FOLDER, true));
63 pButton->SetActionId(ID_BUTTON_CHOOSE_IMAGE_FOLDER_PATH);
64 pButton->AddActionEventListener(*this);
67 pButton = static_cast<Button*>(GetControl(IDC_BUTTON_CHOOSE_FEATURE_SET_PATH, true));
70 pButton->SetActionId(ID_BUTTON_CHOOSE_FEATURE_SET_PATH);
71 pButton->AddActionEventListener(*this);
78 GeneratePanel::OnTerminating(void)
86 GeneratePanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
88 SceneManager* pSceneManager = SceneManager::GetInstance();
89 AppAssert(pSceneManager);
93 case ID_BUTTON_CHOOSE_FEATURE_SET_PATH:
95 pSceneManager->GoForward(
96 ForwardSceneTransition("ChooseNewFeatureSetScene",
97 SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN,
98 SCENE_HISTORY_OPTION_ADD_HISTORY,
99 SCENE_DESTROY_OPTION_KEEP),0);
103 case ID_BUTTON_CHOOSE_IMAGE_FOLDER_PATH:
105 pSceneManager->GoForward(
106 ForwardSceneTransition("ChooseImageScene",
107 SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN,
108 SCENE_HISTORY_OPTION_ADD_HISTORY,
109 SCENE_DESTROY_OPTION_KEEP), 0);
117 GeneratePanel::OnSceneActivatedN(
118 const Tizen::Ui::Scenes::SceneId& previousSceneId,
119 const Tizen::Ui::Scenes::SceneId& currentSceneId,
120 Tizen::Base::Collection::IList* pArgs)
122 if ((previousSceneId == "ChooseImageScene") && pArgs)
124 if (pArgs->GetCount() > 0)
126 __currentImagePath = *(dynamic_cast<String*>(pArgs->GetAt(0)));
129 else if ((previousSceneId == "ChooseNewFeatureSetScene") && pArgs)
131 if (pArgs->GetCount() > 0)
133 __currentFeaturePath = *(dynamic_cast<String*>(pArgs->GetAt(0)));
139 pArgs->RemoveAll(true);
143 Label* pLabel = null;
144 pLabel = static_cast<Label*>(GetControl(IDC_CREATE_FEATRUE_SET_LABEL, true));
147 pLabel->SetText(__currentFeaturePath);
150 pLabel = static_cast<Label*>(GetControl(IDC_CHOOSE_IMAGE_FOLDER_LABEL, true));
153 pLabel->SetText(__currentImagePath);
159 GeneratePanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
160 const Tizen::Ui::Scenes::SceneId& nextSceneId)
165 GeneratePanel::OnImageProcessed(int imNo, int total)
167 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
168 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(IDF_FORM, true));
170 pForm->OnImageProcessed(imNo, total);
174 GeneratePanel::OnFinish(void)
176 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
177 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(IDF_FORM, true));
180 result res = pForm->GetFeatureManager()->Flush(&__currentFeaturePath);
182 AppLog("Result:: %s %ls", GetErrorMessage(res), __currentFeaturePath.GetPointer());
187 GeneratePanel::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
191 case GeneratePanel::REQUEST_GENERATE_FEATURE_SET:
193 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
194 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(IDF_FORM, true));
195 pForm->GetFeatureManager()->DeleteAllFeatures();
196 pForm->AppendImageFolder(__currentImagePath, this);