make not use navigation for pages except MediaHubMain due to memory comsumption.
authorcskim <charles0.kim@samsung.com>
Sat, 29 Apr 2017 09:08:18 +0000 (18:08 +0900)
committercskim <charles0.kim@samsung.com>
Sat, 29 Apr 2017 09:28:51 +0000 (18:28 +0900)
Add ContentPageEx for handing appearing, disappearing memory control and back key handling.

Change-Id: Ibbfc31fc614be1810965a2f673b80db4223ee86e

20 files changed:
TVMediaHub/TVMediaHub.Tizen/Controls/ContentPageEx.cs [new file with mode: 0644]
TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.cs
TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj
TVMediaHub/TVMediaHub.Tizen/TVMediaHub.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerSlideShow.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerSlideShow.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml [new file with mode: 0644]
TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml.cs [new file with mode: 0644]
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoPlayer.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoPlayer.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs

diff --git a/TVMediaHub/TVMediaHub.Tizen/Controls/ContentPageEx.cs b/TVMediaHub/TVMediaHub.Tizen/Controls/ContentPageEx.cs
new file mode 100644 (file)
index 0000000..1a110b8
--- /dev/null
@@ -0,0 +1,39 @@
+using System;
+using Xamarin.Forms;
+
+namespace TVMediaHub.Tizen.Controls
+{
+    public abstract class ContentPageEx : ContentPage
+    {
+        protected EventHandler OnBackButtonPressedHandler { set; get; }
+
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+            InitializePage();
+        }
+
+        protected override void OnDisappearing()
+        {
+            base.OnDisappearing();
+            FinalizePage();
+            GC.Collect();
+        }
+
+        protected override bool OnBackButtonPressed()
+        {
+            if(OnBackButtonPressedHandler != null)
+            {
+                OnBackButtonPressedHandler.Invoke(this, EventArgs.Empty);
+                return true;
+            }
+
+            Program.TransitionToMain();
+            return true;
+        }
+
+        protected abstract void InitializePage();
+
+        protected abstract void FinalizePage();
+    }
+}
index 22a739c..bdc9ad8 100644 (file)
  */
 
 using Tizen.Xamarin.Forms.Extension.Renderer;
+using Xamarin.Forms;
 
 namespace TVMediaHub.Tizen
 {
     class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
     {
         public static Program Instance;
+        private static App app;
 
         protected override void OnCreate()
         {
             base.OnCreate();
-            var app = new App(MainWindow.ScreenSize.Width,
+            app = new App(MainWindow.ScreenSize.Width,
                 MainWindow.ScreenSize.Height,
                 MainWindow.ScreenDpi.X,
                 ElmSharp.Elementary.GetScale(),
@@ -33,6 +35,15 @@ namespace TVMediaHub.Tizen
             LoadApplication(app);
         }
 
+        public static void TransitionTo(ContentPage page)
+        {
+            app.TransitionTo(page);
+        }
+        public static void TransitionToMain()
+        {
+            app.TransitionToMain();
+        }
+
         static void Main(string[] args)
         {
             Instance = new Program();
index db4c274..db78f6c 100755 (executable)
@@ -68,6 +68,7 @@
     <Compile Include="TVMediaHub.cs" />
     <Compile Include="TVMediaHub.Tizen.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Controls\ContentPageEx.cs" />
     <Compile Include="Utils\DbgPort.cs" />
     <Compile Include="Utils\EasingFunction.cs" />
     <Compile Include="Utils\NinePatch.xaml.cs">
     <Compile Include="Views\ImageTab.xaml.cs">
       <DependentUpon>ImageTab.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\SimpleImageViewer.xaml.cs">
+      <DependentUpon>SimpleImageViewer.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\ImageViewer.xaml.cs">
       <DependentUpon>ImageViewer.xaml</DependentUpon>
     </Compile>
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Views\SimpleImageViewer.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
                Other similar extension points exist, see Microsoft.Common.targets.
index caa6798..b6b325b 100755 (executable)
@@ -19,7 +19,9 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using TVMediaHub.Tizen;
 using TVMediaHub.Tizen.Utils;
+using TVMediaHub.Tizen.Views;
 using Xamarin.Forms;
 
 namespace TVMediaHub
@@ -50,7 +52,16 @@ namespace TVMediaHub
                 SizeUtils.SetModelName(modelName);
             }
             MainWindow = window;
-            MainPage = new NavigationPage(new Tizen.Views.MediaHubMainPage());
+            TransitionToMain();
+        }
+
+        public void TransitionTo(ContentPage page)
+        {
+            MainPage = page;
+        }
+        public void TransitionToMain()
+        {
+            MainPage = new NavigationPage(new MediaHubMainPage());
         }
 
         protected override void OnStart()
index 742c5c7..fbc8312 100755 (executable)
@@ -34,7 +34,6 @@ namespace TVMediaHub.Tizen.ViewModels
     {
 
         public ObservableCollection<GroupItem> ImageList { get; set; }
-        public Command SetSelectedImageCommand { get; set; }
 
         private int displayingImageIndex;
         private int DisplayingImageIndex
@@ -53,7 +52,7 @@ namespace TVMediaHub.Tizen.ViewModels
                 }
 
                 displayingImageIndex = value;
-                OnPropertyChanged("CurrentImage");
+                //OnPropertyChanged("CurrentImage");
             }
         }
         public ImageViewerInfomation CurrentImage
index 8f38156..ebc690b 100755 (executable)
@@ -67,9 +67,9 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        public static readonly BindableProperty ImageInfoProperty = BindableProperty.Create("ImagePlayList", typeof(MediaInformation), typeof(ImageItem), null);
+        public static readonly BindableProperty ImageInfoProperty = BindableProperty.Create("SelectedImage", typeof(MediaInformation), typeof(ImageItem), null);
 
-        public MediaInformation ImagePlayList
+        public MediaInformation SelectedImage
         {
             set
             {
@@ -90,29 +90,40 @@ namespace TVMediaHub.Tizen.Views
             PropertyChanged += ImageTabPropertyChanged;
         }
 
+
         private void InitializeSize()
         {
-            WidthRequest = SizeUtils.GetHeightSize(332);
-            HeightRequest = SizeUtils.GetHeightSize(332);
+            int h332 = SizeUtils.GetHeightSize(332);
+            int w332 = SizeUtils.GetWidthSize(332);
+            int h76 = SizeUtils.GetHeightSize(76);
+            int w76 = SizeUtils.GetWidthSize(76);
+            int h64 = SizeUtils.GetHeightSize(64);
+            int w64 = SizeUtils.GetWidthSize(64);
+            int h20 = SizeUtils.GetHeightSize(20);
+            int w20 = SizeUtils.GetWidthSize(20);
+
 
-            ImageBounds = new Rectangle(SizeUtils.GetWidthSize(-76), SizeUtils.GetHeightSize(-76), SizeUtils.GetWidthSize(332), SizeUtils.GetHeightSize(332));
-            ImageFocusedBounds = new Rectangle(SizeUtils.GetWidthSize(-64), SizeUtils.GetHeightSize(-64), SizeUtils.GetWidthSize(332), SizeUtils.GetHeightSize(332));
+            WidthRequest = h332;
+            HeightRequest = h332;
 
-            ImageAreaNormalBounds = new Rectangle(SizeUtils.GetWidthSize(76), SizeUtils.GetHeightSize(76), SizeUtils.GetWidthSize(180), SizeUtils.GetHeightSize(180));
-            ImageAreaFocusedBounds = new Rectangle(SizeUtils.GetWidthSize(64), SizeUtils.GetHeightSize(64), SizeUtils.GetWidthSize(204), SizeUtils.GetHeightSize(204));
+            ImageBounds = new Rectangle(-w76, -h76, w332, h332);
+            ImageFocusedBounds = new Rectangle(-w64, -h64, w332, h332);
+
+            ImageAreaNormalBounds = new Rectangle(w76, h76, SizeUtils.GetWidthSize(180), SizeUtils.GetHeightSize(180));
+            ImageAreaFocusedBounds = new Rectangle(w64, h64, SizeUtils.GetWidthSize(204), SizeUtils.GetHeightSize(204));
 
             ShadowNormalBounds = new Rectangle(SizeUtils.GetWidthSize(12), SizeUtils.GetWidthSize(12), SizeUtils.GetWidthSize(308), SizeUtils.GetHeightSize(308));
-            ShadowFocusedBounds = new Rectangle(0, 0, SizeUtils.GetWidthSize(332), SizeUtils.GetHeightSize(332));
+            ShadowFocusedBounds = new Rectangle(0, 0, w332, h332);
 
-            ImgFocused.BorderLeft = SizeUtils.GetWidthSize(20);
-            ImgFocused.BorderRight = SizeUtils.GetWidthSize(20);
-            ImgFocused.BorderTop = SizeUtils.GetHeightSize(20);
-            ImgFocused.BorderBottom = SizeUtils.GetHeightSize(20);
+            ImgFocused.BorderLeft = w20;
+            ImgFocused.BorderRight = w20;
+            ImgFocused.BorderTop = h20;
+            ImgFocused.BorderBottom = h20;
 
-            ImgDimmed.BorderLeft = SizeUtils.GetWidthSize(20);
-            ImgDimmed.BorderRight = SizeUtils.GetWidthSize(20);
-            ImgDimmed.BorderTop = SizeUtils.GetHeightSize(20);
-            ImgDimmed.BorderBottom = SizeUtils.GetHeightSize(20);
+            ImgDimmed.BorderLeft = w20;
+            ImgDimmed.BorderRight = w20;
+            ImgDimmed.BorderTop = h20;
+            ImgDimmed.BorderBottom = h20;
         }
 
         public Button GetFocusArea()
@@ -137,9 +148,9 @@ namespace TVMediaHub.Tizen.Views
             }
             else
             {
-                OnItemClickedHandler.Invoke(ImagePlayList);
+                OnItemClickedHandler.Invoke(SelectedImage);
 
-                PushNavigationPage();
+                Program.TransitionTo(new SimpleImageViewer());
             }
         }
 
@@ -191,11 +202,6 @@ namespace TVMediaHub.Tizen.Views
 
             return result;
         }
-        private async void PushNavigationPage()
-        {
-            await Navigation.PushAsync(new ImageViewer());
-        }
-
 
         private async void OnItemFocused(object sender, FocusEventArgs e)
         {
@@ -237,5 +243,6 @@ namespace TVMediaHub.Tizen.Views
                 IsLoaded = true;
             }
         }
+
     }
 }
index bf1bb62..3d265d7 100755 (executable)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.ImageTab"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
              xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
              xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
              ItemsSource="{Binding ImageList}"
@@ -43,4 +44,4 @@
             <Label x:Name="LabelNoContents" Text="No content to display" FontFamily="Breeze Sans Light" TextColor="#33FFFFFF" HorizontalOptions="Center"/>
         </StackLayout>
     </RelativeLayout>
-</ContentPage>
\ No newline at end of file
+</mh:ContentPageEx>
\ No newline at end of file
index 4e979d4..42947aa 100755 (executable)
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Threading.Tasks;
 using System.Windows.Input;
-using Tizen.Xamarin.Forms.Extension;
+using TVMediaHub.Tizen.Controls;
 using TVMediaHub.Tizen.DataModels;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
@@ -30,7 +28,7 @@ using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
 
 namespace TVMediaHub.Tizen.Views
 {
-    public partial class ImageTab : ContentPage
+    public partial class ImageTab : ContentPageEx
     {
         private bool IsContentReady = false;
 
@@ -91,20 +89,46 @@ namespace TVMediaHub.Tizen.Views
         {
             BindingContext = ImageTabViewModelLocator.ViewModel;
             InitializeComponent();
-            Init();
+
+            InitializeData();
             InitializeSize();
             InitializeFooter();
             ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
         }
 
-        private void Init()
+
+        private void InitializeData()
         {
             BottomButtonList = new List<KeyValuePair<double, Button>>();
         }
 
-        protected override void OnAppearing()
+        private void InitializeSize()
+        {
+            GalleryContentView.Padding = new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(74));
+            GalleryContentView.Spacing = SizeUtils.GetWidthSize(36);
+            ImgNoContents.Margin = new Thickness(0, Utils.SizeUtils.GetHeightSize(266), 0, Utils.SizeUtils.GetHeightSize(28));
+            ImgNoContents.HeightRequest = Utils.SizeUtils.GetHeightSize(88);
+            ImgNoContents.WidthRequest = Utils.SizeUtils.GetWidthSize(68);
+            LabelNoContents.HeightRequest = Utils.SizeUtils.GetHeightSize(32);
+            LabelNoContents.FontSize = Utils.SizeUtils.GetFontSize(28);
+        }
+
+        private void InitializeFooter()
+        {
+
+            FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
+
+            FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
+
+            FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
+
+            FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
+            FooterDelete.OKButtonEvent += OnOKClicked;
+            FooterDelete.CancelButtonEvent += OnCancelClicked;
+        }
+
+        protected override void InitializePage()
         {
-            base.OnAppearing();
             if (IsContentReady == false)
             {
                 GetInformationsCommand?.Execute("");
@@ -112,6 +136,12 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
+        protected override void FinalizePage()
+        {
+            ItemsSource.Clear();
+            IsContentReady = false;
+        }
+
         private void ItemsSourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
             if (e.Action.ToString().Equals("Add"))
@@ -240,21 +270,6 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-
-        private void InitializeFooter()
-        {
-
-            FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
-            FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
-            FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
-
-            FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
-            FooterDelete.OKButtonEvent += OnOKClicked;
-            FooterDelete.CancelButtonEvent += OnCancelClicked;
-        }
-
         private void OnCancelClicked(object sender, EventArgs e)
         {
             DeleteModeChangeCommand?.Execute("");
@@ -294,16 +309,5 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        private void InitializeSize()
-        {
-            GalleryContentView.Padding = new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(74));
-            GalleryContentView.Spacing = SizeUtils.GetWidthSize(36);
-            ImgNoContents.Margin = new Thickness(0, Utils.SizeUtils.GetHeightSize(266), 0, Utils.SizeUtils.GetHeightSize(28));
-            ImgNoContents.HeightRequest = Utils.SizeUtils.GetHeightSize(88);
-            ImgNoContents.WidthRequest = Utils.SizeUtils.GetWidthSize(68);
-            LabelNoContents.HeightRequest = Utils.SizeUtils.GetHeightSize(32);
-            LabelNoContents.FontSize = Utils.SizeUtils.GetFontSize(28);
-        }
-
     }
 }
index bcbaa2a..06c6215 100755 (executable)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.ImageViewerSlideShow"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
              xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
              ItemsSource="{Binding ImagePlayList}"
              Speed="{Binding Speed}"
@@ -34,4 +35,4 @@
               BorderRight="2"
               Source="img_tizen_gradient_topbottom.9.png" />
   </RelativeLayout>
-</ContentPage>
\ No newline at end of file
+</mh:ContentPageEx>
\ No newline at end of file
index 178cbfa..29ae9a4 100755 (executable)
@@ -17,6 +17,7 @@
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using TVMediaHub.Tizen.Controls;
 using TVMediaHub.Tizen.DataModels;
 using TVMediaHub.Tizen.Utils;
 using TVMediaHub.Tizen.ViewModels;
@@ -24,9 +25,9 @@ using Xamarin.Forms;
 
 namespace TVMediaHub.Tizen.Views
 {
-    public partial class ImageViewerSlideShow : ContentPage
+    public partial class ImageViewerSlideShow : ContentPageEx
     {
-        private List<ImageViewerInfomation> imageList;
+        private List<ImageViewerInfomation> imageList = new List<ImageViewerInfomation>();
 
         private static bool isBackKeyPressed = false;
 
@@ -64,29 +65,39 @@ namespace TVMediaHub.Tizen.Views
 
         public ImageViewerSlideShow()
         {
-            imageList = new List<ImageViewerInfomation>();
-            PropertyChanged += OnPropertyChanged;
             BindingContext = ImageTabViewModelLocator.ViewModel;
             InitializeComponent();
-            NavigationPage.SetHasNavigationBar(this, false);
+
+            OnBackButtonPressedHandler += (s, e) =>
+            {
+                isBackKeyPressed = true;
+                Program.TransitionTo(new SimpleImageViewer());
+            };
 
             ViewSlideShow();
         }
 
-        private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        protected override void InitializePage()
         {
-            if (e.PropertyName.Equals("ItemsSource"))
-            {
-                imageList.Clear();
-                foreach (var item in ItemsSource)
-                {
-                    imageList.Add(item);
-                }
-            }
+            isBackKeyPressed = false;
+        }
+
+        protected override void FinalizePage()
+        {
+            ViewExtensions.CancelAnimations(CurrentThumbnail);
+            ViewExtensions.CancelAnimations(NextThumbnail);
+
+            CurrentImage = imageList.Find(x => x.FilePath.Equals((CurrentThumbnail.Source as FileImageSource).File));
+            imageList.Clear();
         }
 
         private void ViewSlideShow()
         {
+            foreach (var item in ItemsSource)
+            {
+                imageList.Add(item);
+            }
+
             if (imageList.Count > 0)
             {
                 if (Effect.Equals(SlideShowEffect.Dissolve))
@@ -104,7 +115,7 @@ namespace TVMediaHub.Tizen.Views
         {
             int delayTime = 2000;
 
-            switch(Speed)
+            switch (Speed)
             {
                 case SlideShowSpeed.Slow:
                     delayTime *= 2;
@@ -163,7 +174,7 @@ namespace TVMediaHub.Tizen.Views
                     return;
                 }
 
-                await Navigation.PopAsync();
+                Program.TransitionTo(new SimpleImageViewer());
             }
             catch (Exception e)
             {
@@ -198,7 +209,7 @@ namespace TVMediaHub.Tizen.Views
                     return;
                 }
 
-                await Navigation.PopAsync();
+                Program.TransitionTo(new SimpleImageViewer());
             }
             catch (Exception e)
             {
@@ -206,30 +217,5 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        protected override void OnAppearing()
-        {
-            base.OnAppearing();
-
-            isBackKeyPressed = false;
-        }
-
-        protected override void OnDisappearing()
-        {
-            base.OnDisappearing();
-
-            ViewExtensions.CancelAnimations(CurrentThumbnail);
-            ViewExtensions.CancelAnimations(NextThumbnail);
-
-            CurrentImage = imageList.Find(x => x.FilePath.Equals((CurrentThumbnail.Source as FileImageSource).File));
-        }
-
-        protected override bool OnBackButtonPressed()
-        {
-            isBackKeyPressed = true;
-
-            Navigation.PopAsync();
-
-            return isBackKeyPressed;
-        }
     }
 }
index 23b50e9..4e08c8f 100755 (executable)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.ImageViewerZoom"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
              xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
              xmlns:Controls="clr-namespace:TVMediaHub.Tizen.Controls"
              SavedRotation="{Binding CurrentImage.SavedRotation}">
@@ -83,4 +84,4 @@
       </Grid>
     </RelativeLayout>
   </RelativeLayout>
-</ContentPage>
\ No newline at end of file
+</mh:ContentPageEx>
\ No newline at end of file
index 57c85a7..fae6e72 100755 (executable)
@@ -26,7 +26,7 @@ using System;
 
 namespace TVMediaHub.Tizen.Views
 {
-    public partial class ImageViewerZoom : ContentPage
+    public partial class ImageViewerZoom : ContentPageEx
     {
         private static string TAG = "mediahub";
         private static List<string> MoveDirection = new List<string> { "Up", "Down", "Left", "Right" };
@@ -36,20 +36,90 @@ namespace TVMediaHub.Tizen.Views
         private static double zoomRatio = 1.5;
         private ElmSharp.ImageOrientation imgOrientation = ElmSharp.ImageOrientation.None;
 
-        ElmSharp.Rectangle backgroundThumbnail = null;
-        ElmSharp.Image thumbnailImg = null;
-        ElmSharp.Image thumbnailDim = null;
-        ElmSharp.Image clippingImg = null;
-        ElmSharp.Rectangle clipper = null;
-        ElmSharp.Image clipperBorder = null;
+        private ElmSharp.Rectangle backgroundThumbnail;
+        private ElmSharp.Image thumbnailImg;
+        private ElmSharp.Image thumbnailDim;
+        private ElmSharp.Image clippingImg;
+        private ElmSharp.Rectangle clipper;
+        private ElmSharp.Image clipperBorder;
 
         public static readonly BindableProperty SavedRotationProperty = BindableProperty.Create("SavedRotation", typeof(double), typeof(ImageViewerZoom), default(double));
+
         public double SavedRotation
         {
             get { return (double)GetValue(SavedRotationProperty); }
             set { SetValue(SavedRotationProperty, value); }
         }
 
+
+        public ImageViewerZoom()
+        {
+            BindingContext = ImageTabViewModelLocator.ViewModel;
+            InitializeComponent();
+
+            int BackKeyInfoLabelSize = SizeUtils.GetFontSize(28);
+            BackKeyInfoLabel.FontSize = BackKeyInfoLabelSize;
+            Toast.DisplayText("Press [Back] to Escape from Zoom mode.");
+
+            /// Set the current image
+            setCurrentImage();
+
+            /// Create the mini map
+            createMiniMap();
+
+            OnBackButtonPressedHandler += (s, e) =>
+            {
+                Program.TransitionTo(new SimpleImageViewer());
+            };
+        }
+
+        protected override void InitializePage()
+        {
+            /// Grabs the hw keys to move the given image
+            grabMoveKeys();
+        }
+
+        protected override void FinalizePage()
+        {
+            ungrabMoveKeys();
+
+            if (backgroundThumbnail != null)
+            {
+                backgroundThumbnail.Unrealize();
+                backgroundThumbnail = null;
+            }
+
+            if (thumbnailImg != null)
+            {
+                thumbnailImg.Unrealize();
+                thumbnailImg = null;
+            }
+
+            if (thumbnailDim != null)
+            {
+                thumbnailDim.Unrealize();
+                thumbnailDim = null;
+            }
+
+            if (clippingImg != null)
+            {
+                clippingImg.Unrealize();
+                clippingImg = null;
+            }
+
+            if (clipper != null)
+            {
+                clipper.Unrealize();
+                clipper = null;
+            }
+
+            if (clipperBorder != null)
+            {
+                clipperBorder.Unrealize();
+                clipperBorder = null;
+            }
+        }
+
         /// <summary>
         /// Grabs the hw keys to move the given image
         /// </summary>
@@ -164,26 +234,6 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        public ImageViewerZoom()
-        {
-            BindingContext = ImageTabViewModelLocator.ViewModel;
-            InitializeComponent();
-            NavigationPage.SetHasNavigationBar(this, false);
-
-            /// Grabs the hw keys to move the given image
-            grabMoveKeys();
-
-            int BackKeyInfoLabelSize = SizeUtils.GetFontSize(28);
-            BackKeyInfoLabel.FontSize = BackKeyInfoLabelSize;
-            Toast.DisplayText("Press [Back] to Escape from Zoom mode.");
-
-            /// Set the current image
-            setCurrentImage();
-
-            /// Create the mini map
-            createMiniMap();
-        }
-
         private void setCurrentImage()
         {
             CurrentImage.WidthRequest = App.MainWindow.Geometry.Width * zoomRatio;
@@ -319,54 +369,12 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        protected override void OnDisappearing()
-        {
-            base.OnDisappearing();
-
-            ungrabMoveKeys();
-
-            if (backgroundThumbnail != null)
-            {
-                backgroundThumbnail.Unrealize();
-                backgroundThumbnail = null;
-            }
-
-            if (thumbnailImg != null)
-            {
-                thumbnailImg.Unrealize();
-                thumbnailImg = null;
-            }
-
-            if (thumbnailDim != null)
-            {
-                thumbnailDim.Unrealize();
-                thumbnailDim = null;
-            }
-
-            if (clippingImg != null)
-            {
-                clippingImg.Unrealize();
-                clippingImg = null;
-            }
-
-            if (clipper != null)
-            {
-                clipper.Unrealize();
-                clipper = null;
-            }
-
-            if (clipperBorder != null)
-            {
-                clipperBorder.Unrealize();
-                clipperBorder = null;
-            }
-        }
-
         protected override void LayoutChildren(double x, double y, double width, double height)
         {
             base.LayoutChildren(x, y, width, height);
             GradientDim.HeightRequest = height;
             GradientDim.WidthRequest = width;
         }
+
     }
 }
index 06cf001..56edb97 100755 (executable)
@@ -33,6 +33,13 @@ namespace TVMediaHub.Tizen.Views
             NavigationPage.SetHasNavigationBar(this, true);
         }
 
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+
+            CurrentPage = Children[1];
+        }
+
         protected override bool OnBackButtonPressed()
         {
             SynchronizationContext.Current.Post(async (o) =>
diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml
new file mode 100644 (file)
index 0000000..89577e8
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="TVMediaHub.Tizen.Views.SimpleImageViewer"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
+             xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
+             xmlns:Controls="clr-namespace:TVMediaHub.Tizen.Controls"
+             SavedRotationCommand="{Binding SavedRotationCommand}"
+             NavigationCommand="{Binding NavigationCommand}"
+             SetSlideShowSpeedCommand="{Binding SetSlideShowSpeedCommand}"
+             SetSlideShowEffectCommand="{Binding SetSlideShowEffectCommand}"
+             CurrentImage="{Binding CurrentImage}">
+  <RelativeLayout>
+    <Image x:Name="Thumb1"
+           Aspect="AspectFill" />
+    <Utils:NinePatch x:Name="GradientDim"
+                     VerticalOptions="Center"
+                     HorizontalOptions="Center"
+                     Aspect="Fill"
+                     BorderLeft="20"
+                     BorderTop="20"
+                     BorderRight="20"
+                     BorderBottom="20"
+                     Source="img_gradient_topbottom.9.png" />
+    <Grid x:Name="MainGrid"
+          RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+          RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}" >
+      <Grid.RowDefinitions>
+        <RowDefinition Height="062960*" />
+        <RowDefinition Height="046300*" />
+        <RowDefinition Height="001850*" />
+        <RowDefinition Height="029630*" />
+        <RowDefinition Height="770370*" />
+        <RowDefinition Height="044445*" />
+        <RowDefinition Height="044445*" />
+      </Grid.RowDefinitions>
+      <Grid.RowSpacing>0</Grid.RowSpacing>
+      <Grid.ColumnDefinitions>
+        <ColumnDefinition Width="050000*" />
+        <ColumnDefinition Width="025000*" />
+        <ColumnDefinition Width="029167*" />
+        <ColumnDefinition Width="025000*" />
+        <ColumnDefinition Width="153125*" />
+        <ColumnDefinition Width="040625*" />
+        <ColumnDefinition Width="353125*" />
+        <ColumnDefinition Width="040625*" />
+        <ColumnDefinition Width="154167*" />
+        <ColumnDefinition Width="025000*" />
+        <ColumnDefinition Width="032291*" />
+        <ColumnDefinition Width="021875*" />
+        <ColumnDefinition Width="050000*" />
+      </Grid.ColumnDefinitions>
+      <Grid.ColumnSpacing>0</Grid.ColumnSpacing>
+
+      <Label Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="11" x:Name="TitleLabel"
+             Text="{Binding CurrentImage.Title}" FontFamily="Breeze Sans Bold" TextColor="White" HorizontalTextAlignment="Start"/>
+      <Label Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="11" x:Name="DateLabel"
+             Text="{Binding CurrentImage.Date}" FontFamily="Breeze Sans Light" TextColor="White" HorizontalTextAlignment="Start"/>
+
+      <Image x:Name="RotateBg" Grid.Row="5" Grid.Column="1" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="1" x:Name="RotateBtn" Opacity="0"
+              Clicked="RotateBtnClicked"/>
+      <Controls:CustomImageButton x:Name="RotateImage"
+                                  Type="Viewer" SubType="Rotate"
+                                  Grid.Row="5" Grid.Column="1"
+                                  Source="btn_viewer_control_rotate_normal.png" />
+
+      <Image x:Name="ZoomBg" Grid.Row="5" Grid.Column="3" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="3" x:Name="ZoomBtn" Opacity="0"
+              Clicked="ZoomBtnClicked" />
+      <Controls:CustomImageButton x:Name="ZoomImage"
+                                  Type="Viewer" SubType="Zoom"
+                                  Grid.Row="5" Grid.Column="3"
+                                  Source="btn_viewer_control_zoom_normal.png" />
+
+      <Image x:Name="LeftNaviBg" Grid.Row="5" Grid.Column="5" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="5" x:Name="LeftNaviBtn" Opacity="0"
+              Clicked="LeftBtnClicked" />
+      <Controls:CustomImageButton x:Name="LeftImage"
+                                  Type="Viewer" SubType="Left"
+                                  Grid.Row="5" Grid.Column="5"
+                                  Source="btn_viewer_control_left_normal.png" />
+
+      <Image x:Name="RightNaviBg"  Grid.Row="5" Grid.Column="7" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="7" x:Name="RightNaviBtn" Opacity="0"
+              Clicked="RightBtnClicked" />
+      <Controls:CustomImageButton x:Name="RightImage"
+                                  Grid.Row="5" Grid.Column="7"
+                                  Type="Viewer" SubType="Right"
+                                  Source="btn_viewer_control_right_normal.png" />
+
+      <Image x:Name="SlideShowBg" Grid.Row="5" Grid.Column="9" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="9" x:Name="SlideShowBtn" Opacity="0"
+              Clicked="SlideShowBtnClicked"/>
+      <Controls:CustomImageButton x:Name="SlideShowImage"
+                                  Type="Viewer" SubType="Video"
+                                  Grid.Row="5" Grid.Column="9"
+                                  Source="btn_viewer_control_video_normal.png" />
+
+      <Image x:Name="OptionBG" Grid.Row="5" Grid.Column="11" Source="btn_viewer_control_focused.png" Opacity="0"/>
+      <Button Grid.Row="5" Grid.Column="11" x:Name="OptionBtn" Opacity="0"
+              Clicked="OptionBtnClicked"/>
+      <Controls:CustomImageButton x:Name="OptionImage"
+                                  Type="Viewer" SubType="Option"
+                                  Grid.Row="5" Grid.Column="11"
+                                  Source="btn_viewer_control_option_normal.png" />
+    </Grid>
+    <BoxView x:Name="PopupAnchor"
+             Opacity="0"
+             RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1333}"
+             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.177}"
+             RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.6963}"
+             RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.7729}" />
+  </RelativeLayout>
+</mh:ContentPageEx>
\ No newline at end of file
diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/SimpleImageViewer.xaml.cs
new file mode 100644 (file)
index 0000000..87f084c
--- /dev/null
@@ -0,0 +1,562 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Input;
+using Tizen.Xamarin.Forms.Extension;
+using TVMediaHub.Tizen.Controls;
+using TVMediaHub.Tizen.DataModels;
+using TVMediaHub.Tizen.Utils;
+using TVMediaHub.Tizen.ViewModels;
+using Xamarin.Forms;
+
+namespace TVMediaHub.Tizen.Views
+{
+    public partial class SimpleImageViewer : ContentPageEx
+    {
+        private bool isRotationRunning;
+        private bool isOptionPopupShowing;
+        private bool isSpeedOptionPopupShowing;
+        private bool isEffectOptionPopupShowing;
+
+        private ContextPopup optionPopup;
+        private ContextPopup speedOptionPopup;
+        private ContextPopup effectOptionPopup;
+
+        private object focusedButton;
+
+        private static string ReturnKeyName = "Return";
+
+        public static readonly BindableProperty SavedRotationCommandProperty = BindableProperty.Create("SavedRotationCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+        public ICommand SavedRotationCommand
+        {
+            get { return (ICommand)GetValue(SavedRotationCommandProperty); }
+            set { SetValue(SavedRotationCommandProperty, value); }
+        }
+
+        public static readonly BindableProperty NavigationCommandProperty = BindableProperty.Create("NavigationCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+        public ICommand NavigationCommand
+        {
+            get { return (ICommand)GetValue(NavigationCommandProperty); }
+            set { SetValue(NavigationCommandProperty, value); }
+        }
+
+        public static readonly BindableProperty SetSlideShowSpeedCommandProperty = BindableProperty.Create("SetSlideShowSpeedCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+        public ICommand SetSlideShowSpeedCommand
+        {
+            get { return (ICommand)GetValue(SetSlideShowSpeedCommandProperty); }
+            set { SetValue(SetSlideShowSpeedCommandProperty, value); }
+        }
+
+        public static readonly BindableProperty SetSlideShowEffectCommandProperty = BindableProperty.Create("SetSlideShowEffectCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+        public ICommand SetSlideShowEffectCommand
+        {
+            get { return (ICommand)GetValue(SetSlideShowEffectCommandProperty); }
+            set { SetValue(SetSlideShowEffectCommandProperty, value); }
+        }
+
+        public static readonly BindableProperty CurrentImageProperty = BindableProperty.Create("CurrentImage", typeof(ImageViewerInfomation), typeof(SimpleImageViewer), null);
+        public ImageViewerInfomation CurrentImage
+        {
+            get { return (ImageViewerInfomation)GetValue(CurrentImageProperty); }
+            set { SetValue(CurrentImageProperty, value); }
+        }
+
+        public SimpleImageViewer()
+        {
+            DbgPort.D("SimpleImageViewer start");
+            BindingContext = ImageTabViewModelLocator.ViewModel;
+            InitializeComponent();
+            InitializeSize();
+
+            SetSlideShowSpeedCommand?.Execute(SlideShowSpeed.Normal);
+            SetSlideShowEffectCommand?.Execute(SlideShowEffect.Dissolve);
+            SavedRotationCommand?.Execute(Convert.ToDouble(-1));
+
+            InitializeCurrentImage();
+            InitializeButtonFocusImage();
+
+            PropertyChanged += ImageViewerPropertyChanged;
+            OnBackButtonPressedHandler += (s, e) =>
+            {
+                if (isOptionPopupShowing)
+                {
+                    optionPopup.Dismiss();
+                    return;
+                }
+
+                if (isSpeedOptionPopupShowing)
+                {
+                    speedOptionPopup.Dismiss();
+                    return;
+                }
+
+                if (isEffectOptionPopupShowing)
+                {
+                    effectOptionPopup.Dismiss();
+                    return;
+                }
+
+                Program.TransitionToMain();
+            };
+            DbgPort.D("SimpleImageViewer end");
+        }
+
+        protected override void InitializePage()
+        {
+            grabReturnKey();
+            RotateBtn.Focus();
+        }
+
+        protected override void FinalizePage()
+        {
+            ungrabReturnKey();
+
+            Image focusedBtnBG = null;
+            CustomImageButton focusedCustomImageBtn = null;
+
+            findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+            if (focusedBtnBG == null || focusedCustomImageBtn == null)
+            {
+                return;
+            }
+
+            focusedBtnBG.Scale = 1;
+            focusedBtnBG.Opacity = 0;
+            focusedCustomImageBtn.OnButtonReleased();
+        }
+
+        private void grabReturnKey()
+        {
+            App.MainWindow.KeyGrab(ReturnKeyName, false);
+
+            App.MainWindow.KeyUp += ReturnKeyUpListener;
+            App.MainWindow.KeyDown += ReturnKeyDownListener;
+        }
+
+        private void ungrabReturnKey()
+        {
+            App.MainWindow.KeyUp -= ReturnKeyUpListener;
+            App.MainWindow.KeyDown -= ReturnKeyDownListener;
+
+            App.MainWindow.KeyUngrab(ReturnKeyName);
+        }
+
+        private void ReturnKeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
+        {
+            DbgPort.D("[ImageViwer] key up : " + e.KeyName);
+
+            if (!e.KeyName.Equals(ReturnKeyName))
+            {
+                return;
+            }
+
+            Image focusedBtnBG = null;
+            CustomImageButton focusedCustomImageBtn = null;
+
+            findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+            if (focusedBtnBG == null || focusedCustomImageBtn == null)
+            {
+                return;
+            }
+
+            focusedBtnBG.ScaleTo(3, 250);
+            focusedBtnBG.FadeTo(1, 250);
+
+            focusedCustomImageBtn.OnButtonReleased();
+        }
+
+        private void ReturnKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
+        {
+            DbgPort.D("[SimpleImageViewer] key Down : " + e.KeyName);
+
+            if (!e.KeyName.Equals(ReturnKeyName))
+            {
+                return;
+            }
+
+            Image focusedBtnBG = null;
+            CustomImageButton focusedCustomImageBtn = null;
+
+            findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+            if (focusedBtnBG == null || focusedCustomImageBtn == null)
+            {
+                return;
+            }
+
+            focusedBtnBG.ScaleTo(1, 250);
+            focusedBtnBG.FadeTo(0, 250);
+
+            focusedCustomImageBtn.OnButtonPressed();
+        }
+
+        private void findFocusedItems(out Image focusedBtnBG, out CustomImageButton focusedCustomImageBtn)
+        {
+            List<Button> buttons = new List<Button> { RotateBtn, ZoomBtn, LeftNaviBtn, RightNaviBtn, SlideShowBtn, OptionBtn };
+            Image[] imageBGs = new Image[6] { RotateBg, ZoomBg, LeftNaviBg, RightNaviBg, SlideShowBg, OptionBG };
+            CustomImageButton[] customImageButtons = new CustomImageButton[6] { RotateImage, ZoomImage, LeftImage, RightImage, SlideShowImage, OptionImage };
+
+            // TODO : what is the reason of this behavior?
+            int index = buttons.FindIndex(x => x.Equals(focusedButton));
+
+            if (index < 0 ||
+                index > imageBGs.Length ||
+                index > customImageButtons.Length)
+            {
+                focusedBtnBG = null;
+                focusedCustomImageBtn = null;
+                return;
+            }
+
+            focusedBtnBG = imageBGs[index];
+            focusedCustomImageBtn = customImageButtons[index];
+        }
+
+        private void InitializeCurrentImage()
+        {
+            Thumb1.Source = CurrentImage.FilePath;
+            Thumb1.WidthRequest = App.MainWindow.Geometry.Width;
+            Thumb1.HeightRequest = App.MainWindow.Geometry.Height;
+            Thumb1.TranslationX = App.MainWindow.Geometry.X;
+            Thumb1.TranslationY = App.MainWindow.Geometry.Y;
+            Thumb1.Rotation = CurrentImage.SavedRotation;
+        }
+
+        private void InitializeSize()
+        {
+            int titleSize = SizeUtils.GetFontSize(44);
+            int dateSize = SizeUtils.GetFontSize(26);
+            TitleLabel.FontSize = titleSize;
+            DateLabel.FontSize = dateSize;
+        }
+
+        private void ImageViewerPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            if (e.PropertyName.Equals("CurrentImage"))
+            {
+                int currentAngle = Convert.ToInt32(CurrentImage.SavedRotation);
+                Thumb1.Source = CurrentImage.FilePath;
+                Thumb1.Scale = (currentAngle == 90 || currentAngle == 270) ? (double)((double)App.MainWindow.Geometry.Height / (double)App.MainWindow.Geometry.Width) : 1;
+                Thumb1.Rotation = CurrentImage.SavedRotation;
+                return;
+            }
+        }
+
+        private void InitializeButtonFocusImage()
+        {
+            int focusedSacle = 3;
+            int unfocusedScale = 1;
+
+            RotateBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                RotateBg.ScaleTo(focusedSacle, 250);
+                RotateBg.FadeTo(1, 250);
+            };
+            ZoomBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                ZoomBg.ScaleTo(focusedSacle, 250);
+                ZoomBg.FadeTo(1, 250);
+            };
+            LeftNaviBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                LeftNaviBg.TranslationX = 7;
+                LeftNaviBg.ScaleTo(focusedSacle, 250);
+                LeftNaviBg.FadeTo(1, 250);
+            };
+            RightNaviBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                RightNaviBg.ScaleTo(focusedSacle, 250);
+                RightNaviBg.FadeTo(1, 250);
+            };
+            SlideShowBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                SlideShowBg.ScaleTo(focusedSacle, 250);
+                SlideShowBg.FadeTo(1, 250);
+            };
+            OptionBtn.Focused += (s, e) =>
+            {
+                focusedButton = s;
+
+                OptionBG.ScaleTo(focusedSacle, 250);
+                OptionBG.FadeTo(1, 250);
+            };
+
+            RotateBtn.Unfocused += (s, e) =>
+            {
+                RotateBg.ScaleTo(unfocusedScale, 250);
+                RotateBg.FadeTo(0, 250);
+            };
+            ZoomBtn.Unfocused += (s, e) =>
+            {
+                ZoomBg.ScaleTo(unfocusedScale, 250);
+                ZoomBg.FadeTo(0, 250);
+            };
+            LeftNaviBtn.Unfocused += (s, e) =>
+            {
+                LeftNaviBg.ScaleTo(unfocusedScale, 250);
+                LeftNaviBg.FadeTo(0, 250);
+            };
+            RightNaviBtn.Unfocused += (s, e) =>
+            {
+                RightNaviBg.ScaleTo(unfocusedScale, 250);
+                RightNaviBg.FadeTo(0, 250);
+            };
+            SlideShowBtn.Unfocused += (s, e) =>
+            {
+                SlideShowBg.ScaleTo(unfocusedScale, 250);
+                SlideShowBg.FadeTo(0, 250);
+            };
+            OptionBtn.Unfocused += (s, e) =>
+            {
+                OptionBG.ScaleTo(unfocusedScale, 250);
+                OptionBG.FadeTo(0, 250);
+            };
+        }
+
+        private async void RotateBtnClicked(object sender, EventArgs e)
+        {
+            if (isRotationRunning)
+            {
+                return;
+            }
+
+            int duration = 350;
+            int rotateAngle = 90;
+            int currentAngle = Convert.ToInt32(Thumb1.Rotation);
+
+            isRotationRunning = true;
+
+#pragma warning disable CS4014
+            Thumb1.ScaleTo((((currentAngle + rotateAngle) == 90 || (currentAngle + rotateAngle) == 270) ? (double)((double)Thumb1.Height / (double)Thumb1.Width) : 1), Convert.ToUInt32(duration), Easing.CubicInOut);
+#pragma warning restore CS4014
+
+            await Thumb1.RotateTo(Thumb1.Rotation + rotateAngle, Convert.ToUInt32(duration), Easing.CubicInOut);
+
+            Thumb1.Rotation = (Thumb1.Rotation == 360) ? 0 : Thumb1.Rotation;
+            SavedRotationCommand?.Execute(Thumb1.Rotation);
+            isRotationRunning = false;
+        }
+
+        private void ZoomBtnClicked(object sender, EventArgs e)
+        {
+            Program.TransitionTo(new ImageViewerZoom());
+        }
+
+        private void LeftBtnClicked(object sender, EventArgs e)
+        {
+            NavigationCommand?.Execute("Left");
+            Program.TransitionTo(new SimpleImageViewer());
+        }
+
+        private void RightBtnClicked(object sender, EventArgs e)
+        {
+            NavigationCommand?.Execute("Right");
+            Program.TransitionTo(new SimpleImageViewer());
+        }
+
+        private void SlideShowBtnClicked(object sender, EventArgs e)
+        {
+            Program.TransitionTo(new ImageViewerSlideShow());
+        }
+
+        private void OptionBtnClicked(object sender, EventArgs e)
+        {
+            createOptionPopup();
+        }
+
+        private void createOptionPopup()
+        {
+            if (isOptionPopupShowing)
+            {
+                return;
+            }
+
+            optionPopup = new ContextPopup
+            {
+                IsAutoHidingEnabled = true,
+                Orientation = ContextPopupOrientation.Vertical,
+                DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left, ContextPopupDirection.Down),
+            };
+
+            optionPopup.Items.Add(new ContextPopupItem("  SLIDE SHOW SPEED  "));
+            optionPopup.Items.Add(new ContextPopupItem("  SLIDE SHOW EFFECT  "));
+
+            optionPopup.SelectedIndexChanged += (s, args) =>
+            {
+                var ctxPopup = s as ContextPopup;
+
+                DbgPort.D("[SimpleImageViewer] Selected Item : " + (ctxPopup.SelectedItem as ContextPopupItem).Label + " (" + ctxPopup.SelectedIndex + ")");
+                switch (ctxPopup.SelectedIndex)
+                {
+                    case 0:
+                        /// Slide Show Speed
+                        createSlideShowSpeedOptionPopup();
+                        break;
+                    case 1:
+                        /// Slide Show Effect
+                        createSlideShowEffectOptionPopup();
+                        break;
+                    default:
+                        break;
+                }
+
+                optionPopup.Dismiss();
+                optionPopup = null;
+            };
+
+            optionPopup.Dismissed += (s, args) =>
+            {
+                isOptionPopupShowing = false;
+            };
+
+            optionPopup.Show(PopupAnchor, (PopupAnchor.Width / 2), PopupAnchor.Height);
+            isOptionPopupShowing = true;
+        }
+
+        private void createSlideShowSpeedOptionPopup()
+        {
+            if (isSpeedOptionPopupShowing)
+            {
+                return;
+            }
+
+            speedOptionPopup = new ContextPopup
+            {
+                IsAutoHidingEnabled = true,
+                Orientation = ContextPopupOrientation.Vertical,
+                DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left, ContextPopupDirection.Down),
+            };
+
+            speedOptionPopup.Items.Add(new ContextPopupItem("              NORMAL             "));
+            speedOptionPopup.Items.Add(new ContextPopupItem("              SLOW              "));
+            speedOptionPopup.Items.Add(new ContextPopupItem("              FAST              "));
+
+
+            speedOptionPopup.SelectedIndexChanged += (s, e) =>
+            {
+                var ctxPopup = s as ContextPopup;
+
+                DbgPort.D("[SlideShowSpeed] Selected Item : " + (ctxPopup.SelectedItem as ContextPopupItem).Label + "(" + ctxPopup.SelectedIndex + ")");
+
+                switch (ctxPopup.SelectedIndex)
+                {
+                    case 0:
+                        /// Normal
+                        SetSlideShowSpeedCommand?.Execute(SlideShowSpeed.Normal);
+                        break;
+                    case 1:
+                        /// Slow
+                        SetSlideShowSpeedCommand?.Execute(SlideShowSpeed.Slow);
+                        break;
+                    case 2:
+                        /// Fast
+                        SetSlideShowSpeedCommand?.Execute(SlideShowSpeed.Fast);
+                        break;
+                    default:
+                        break;
+                }
+
+                speedOptionPopup.Dismiss();
+                speedOptionPopup = null;
+            };
+
+            speedOptionPopup.Dismissed += (s, args) =>
+            {
+                isSpeedOptionPopupShowing = false;
+
+                createOptionPopup();
+            };
+
+            speedOptionPopup.Show(PopupAnchor, (PopupAnchor.Width / 2), PopupAnchor.Height);
+            isSpeedOptionPopupShowing = true;
+        }
+
+        private void createSlideShowEffectOptionPopup()
+        {
+            if (isEffectOptionPopupShowing)
+            {
+                return;
+            }
+
+            effectOptionPopup = new ContextPopup
+            {
+                IsAutoHidingEnabled = true,
+                Orientation = ContextPopupOrientation.Vertical,
+                DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left, ContextPopupDirection.Down),
+            };
+
+            effectOptionPopup.Items.Add(new ContextPopupItem("            DISSOLVE            "));
+            effectOptionPopup.Items.Add(new ContextPopupItem("            FADE OUT            "));
+
+            effectOptionPopup.SelectedIndexChanged += (s, e) =>
+            {
+                var ctxPopup = s as ContextPopup;
+
+                DbgPort.D("[SlideShowEffect] Selected Item : " + (ctxPopup.SelectedItem as ContextPopupItem).Label + "(" + ctxPopup.SelectedIndex + ")");
+
+                switch (ctxPopup.SelectedIndex)
+                {
+                    case 0:
+                        /// Dissolve
+                        SetSlideShowEffectCommand?.Execute(SlideShowEffect.Dissolve);
+                        break;
+                    case 1:
+                        /// Fade out
+                        SetSlideShowEffectCommand?.Execute(SlideShowEffect.FadeOut);
+                        break;
+                    default:
+                        break;
+                }
+
+                effectOptionPopup.Dismiss();
+                effectOptionPopup = null;
+            };
+
+            effectOptionPopup.Dismissed += (s, args) =>
+            {
+                isEffectOptionPopupShowing = false;
+
+                createOptionPopup();
+
+            };
+
+            effectOptionPopup.Show(PopupAnchor, (PopupAnchor.Width / 2), PopupAnchor.Height);
+            isEffectOptionPopupShowing = true;
+        }
+
+        protected override void LayoutChildren(double x, double y, double width, double height)
+        {
+            base.LayoutChildren(x, y, width, height);
+            GradientDim.HeightRequest = height;
+            GradientDim.WidthRequest = width;
+        }
+
+    }
+}
index a84af13..4623a9b 100644 (file)
@@ -201,9 +201,9 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        private async void PushNavigationPage()
+        private void PushNavigationPage()
         {
-            await Navigation.PushAsync(new VideoPlayer());
+            Program.TransitionTo(new VideoPlayer());
         }
 
         private void VideoTabPropertyChanged(object sender, PropertyChangedEventArgs e)
index c002d35..4c6f5ce 100755 (executable)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.VideoPlayer"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
              xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
              xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
              xmlns:Controls="clr-namespace:TVMediaHub.Tizen.Controls"
                 HorizontalTextAlignment="Start"/>
     </RelativeLayout>
   </RelativeLayout>
-</ContentPage>
\ No newline at end of file
+</mh:ContentPageEx>
\ No newline at end of file
index 4edbe87..ab64261 100755 (executable)
@@ -27,15 +27,15 @@ using System.Collections.Generic;
 
 namespace TVMediaHub.Tizen.Views
 {
-    public partial class VideoPlayer : ContentPage
+    public partial class VideoPlayer : ContentPageEx
     {
-        private bool isPlaying = false;
-        private Player playerInstance = null;
-        private Elm.Window fullScreenWindow = null;
-        private PlayerDisplay playerDisplayInstance = null;
+        private bool isPlaying;
+        private Player playerInstance;
+        private Elm.Window fullScreenWindow;
+        private PlayerDisplay playerDisplayInstance;
         private MediaUriSource videoMediaSource;
         private static string ReturnKeyName = "Return";
-        private object focusedButton = null;
+        private object focusedButton;
         private double height72 = SizeUtils.GetHeightSize(72);
 
         public static readonly BindableProperty CurrentVideoProperty = BindableProperty.Create("CurrentVideo", typeof(MediaInformation), typeof(VideoPlayer), null);
@@ -49,7 +49,6 @@ namespace TVMediaHub.Tizen.Views
         {
             BindingContext = VideoTabViewModelLocator.ViewModel;
             InitializeComponent();
-            Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);
             InitializeFontSize();
             TitleLabel.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetFontWeight(FontWeight.Bold);
             TitleLabel.FontSize = SizeUtils.GetFontSize(44);
@@ -59,6 +58,18 @@ namespace TVMediaHub.Tizen.Views
             InitializeButtonFocusImage();
         }
 
+        protected override void InitializePage()
+        {
+            PausePlayBtn.Focus();
+
+            PausePlayBtnClicked(this, null);
+        }
+
+        protected override void FinalizePage()
+        {
+
+        }
+
         private void OptionBtnClicked(object sender, EventArgs e)
         {
             ShowOptionMenu();
@@ -68,7 +79,8 @@ namespace TVMediaHub.Tizen.Views
         {
             // Create Player Display and Window
             fullScreenWindow = new Elm.Window("MediaPlayer");
-            fullScreenWindow.KeyUp += (sender, evasKeyEventArg) => {
+            fullScreenWindow.KeyUp += (sender, evasKeyEventArg) =>
+            {
                 DbgPort.D("KeyPreessed : " + evasKeyEventArg.KeyName);
 
                 if (evasKeyEventArg.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName) == 0)
@@ -363,5 +375,11 @@ namespace TVMediaHub.Tizen.Views
             NumText.FontSize = SizeUtils.GetFontSize(40);
             OptionMenu.IsVisible = false;
         }
+
+        protected override bool OnBackButtonPressed()
+        {
+            Program.TransitionToMain();
+            return true;
+        }
     }
 }
index 9a86b64..0092316 100644 (file)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+<mh:ContentPageEx xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.VideoTab"
+             xmlns:mh="clr-namespace:TVMediaHub.Tizen.Controls"
              xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
              xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
              Title="Movie"
@@ -47,4 +48,4 @@
             <Label x:Name="LabelNoContents" Text="No content to display" FontFamily="Breeze Sans Light" TextColor="#33FFFFFF" HorizontalOptions="Center"/>
         </StackLayout>
     </RelativeLayout>
-</ContentPage>
\ No newline at end of file
+</mh:ContentPageEx>
\ No newline at end of file
index 9c927ca..43682a1 100644 (file)
@@ -17,8 +17,8 @@
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.Threading.Tasks;
 using System.Windows.Input;
+using TVMediaHub.Tizen.Controls;
 using TVMediaHub.Tizen.DataModels;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
@@ -28,7 +28,7 @@ using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
 
 namespace TVMediaHub.Tizen.Views
 {
-    public partial class VideoTab : ContentPage
+    public partial class VideoTab : ContentPageEx
     {
         private bool IsContentReady = false;
         /// <summary>
@@ -111,17 +111,57 @@ namespace TVMediaHub.Tizen.Views
         {
             BindingContext = VideoTabViewModelLocator.ViewModel;
             InitializeComponent();
-            Init();
+            InitializeData();
             InitializeSize();
             InitializeFooter();
             ItemsSource.CollectionChanged += ItemsSource_CollectionChanged;
         }
 
-        private void Init()
+        private void InitializeData()
         {
             BottomButtonList = new List<KeyValuePair<double, Button>>();
         }
 
+        private void InitializeSize()
+        {
+            VideoTabList.Padding = new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(0));
+            VideoTabList.Spacing = SizeUtils.GetWidthSize(36);
+            ImgNoContents.Margin = new Thickness(0, SizeUtils.GetHeightSize(266), 0, SizeUtils.GetHeightSize(28));
+            ImgNoContents.HeightRequest = SizeUtils.GetHeightSize(88);
+            ImgNoContents.WidthRequest = SizeUtils.GetWidthSize(68);
+            LabelNoContents.HeightRequest = SizeUtils.GetHeightSize(32);
+            LabelNoContents.FontSize = SizeUtils.GetFontSize(28);
+        }
+
+        private void InitializeFooter()
+        {
+
+            FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
+
+            FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
+
+            FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
+
+            FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
+            FooterDelete.OKButtonEvent += OnOKClicked;
+            FooterDelete.CancelButtonEvent += OnCancelClicked;
+        }
+
+        protected override void InitializePage()
+        {
+            if (IsContentReady == false)
+            {
+                GetInformationsCommand?.Execute("");
+                IsContentReady = true;
+            }
+        }
+
+        protected override void FinalizePage()
+        {
+            ItemsSource.Clear();
+            IsContentReady = false;
+        }
+
         private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
             if (e.Action.ToString().Equals("Add"))
@@ -256,30 +296,6 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        protected override void OnAppearing()
-        {
-            base.OnAppearing();
-            if (IsContentReady == false)
-            {
-                GetInformationsCommand?.Execute("");
-                IsContentReady = true;
-            }
-        }
-
-        private void InitializeFooter()
-        {
-
-            FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
-            FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
-            FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
-
-            FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
-            FooterDelete.OKButtonEvent += OnOKClicked;
-            FooterDelete.CancelButtonEvent += OnCancelClicked;
-        }
-
         private void OnCancelClicked(object sender, EventArgs e)
         {
             ChangeTabStatusCommand?.Execute("");
@@ -319,15 +335,5 @@ namespace TVMediaHub.Tizen.Views
             }
         }
 
-        private void InitializeSize()
-        {
-            VideoTabList.Padding = new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(0));
-            VideoTabList.Spacing = SizeUtils.GetWidthSize(36);
-            ImgNoContents.Margin = new Thickness(0, SizeUtils.GetHeightSize(266), 0, SizeUtils.GetHeightSize(28));
-            ImgNoContents.HeightRequest = SizeUtils.GetHeightSize(88);
-            ImgNoContents.WidthRequest = SizeUtils.GetWidthSize(68);
-            LabelNoContents.HeightRequest = SizeUtils.GetHeightSize(32);
-            LabelNoContents.FontSize = SizeUtils.GetFontSize(28);
-        }
     }
 }