Add comments for TVApps.Controls
authorHeonjae Jang <heonjae.jang@samsung.com>
Tue, 28 Mar 2017 11:52:23 +0000 (20:52 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:51 +0000 (18:34 +0900)
Change-Id: I428f88bbd72afbfbe7e24ad3924f442972defcb2

TVApps/TVApps/Controls/AppItemCell.xaml.cs
TVApps/TVApps/Controls/AppListView.xaml.cs
TVApps/TVApps/Controls/CustomButton.xaml.cs
TVApps/TVApps/Controls/NinePatchImage.xaml.cs
TVApps/TVApps/Controls/TVButton.xaml.cs

index e76aad6521cf4a715e1b1cce935a3da7365f4178..bc9cb6256818fbbf66867750660ba4e952b23b23 100755 (executable)
@@ -16,7 +16,6 @@
 
 using System;
 using System.ComponentModel;
-using System.Globalization;
 using System.Windows.Input;
 using Xamarin.Forms;
 
@@ -33,10 +32,19 @@ namespace TVApps.Controls
     /// </summary>
     public partial class AppItemCell : ViewCell
     {
+        /// <summary>
+        /// The command will be excuted if the button is clicked
+        /// </summary>
         public ICommand OnClickedCommand { get; set; }
 
+        /// <summary>
+        /// The command will be excuted if the button is focused
+        /// </summary>
         public ICommand OnFocusedCommand { get; set; }
 
+        /// <summary>
+        /// The property for pinned state
+        /// </summary>
         public static readonly BindableProperty IsPinnedProperty = BindableProperty.Create("IsPinned", typeof(bool), typeof(AppItemCell), default(bool));
         public bool IsPinned
         {
@@ -44,6 +52,9 @@ namespace TVApps.Controls
             set { SetValue(IsPinnedProperty, value); }
         }
 
+        /// <summary>
+        /// The property for checked state
+        /// </summary>
         public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create("IsChecked", typeof(bool), typeof(AppItemCell), default(bool));
         public bool IsChecked
         {
@@ -51,6 +62,9 @@ namespace TVApps.Controls
             set { SetValue(IsCheckedProperty, value); }
         }
 
+        /// <summary>
+        /// The property for show state of option menu
+        /// </summary>
         public static readonly BindableProperty IsShowOptionsProperty = BindableProperty.Create("IsShowOptions", typeof(bool), typeof(AppItemCell), default(bool));
         public bool IsShowOptions
         {
@@ -58,6 +72,9 @@ namespace TVApps.Controls
             set { SetValue(IsShowOptionsProperty, value); }
         }
 
+        /// <summary>
+        /// The property for dim state
+        /// </summary>
         public static readonly BindableProperty IsDimProperty = BindableProperty.Create("IsDim", typeof(bool), typeof(AppItemCell), default(bool));
         public bool IsDim
         {
@@ -65,6 +82,9 @@ namespace TVApps.Controls
             set { SetValue(IsDimProperty, value); }
         }
 
+        /// <summary>
+        /// The property for focused state
+        /// </summary>
         public static readonly BindableProperty IsFocusedProperty = BindableProperty.Create("IsFocused", typeof(bool), typeof(AppItemCell), default(bool), BindingMode.TwoWay);
         public bool IsFocused
         {
@@ -72,16 +92,24 @@ namespace TVApps.Controls
             set { SetValue(IsFocusedProperty, value); }
         }
 
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public AppItemCell()
         {
             InitializeComponent();
             OptionMenuPinToggleButton.Text = IsPinned ? "UNPIN" : "PIN";
-
-            PropertyChanged += AppItemCell_PropertyChanged;
-            ButtonTitle.PropertyChanged += ButtonTitle_PropertyChanged;
+            PropertyChanged += AppItemCellPropertyChanged;
+            ButtonTitle.PropertyChanged += ButtonTitlePropertyChanged;
         }
 
-        private void AppItemCell_PropertyChanged(object sender, PropertyChangedEventArgs e)
+        /// <summary>
+        /// Handles AppItemCell Property Changed event
+        /// Runs animation according to property change of AppItemCell
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occurred when property of AppItemCell is changed</param>
+        private void AppItemCellPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName.CompareTo("IsPinned") == 0)
             {
@@ -95,6 +123,7 @@ namespace TVApps.Controls
                 // TODO : Change Animation (Add Pin Contents Item : Unselected)
                 if (IsFocused)
                 {
+                    View.AbortAnimation("CheckedAnimation");
                     View.Animate("CheckedAnimation", (v) =>
                     {
                         var scale = 1.32 - (0.22) * v;
@@ -134,6 +163,10 @@ namespace TVApps.Controls
             }
         }
 
+        /// <summary>
+        /// Changes positon and scale of ButtomImage and TextArea
+        /// </summary>
+        /// <param name="size">Icon Size for changing</param>
         public void ChangeIconSize(IconSize size)
         {
             ButtonImage.ScaleTo((size == IconSize.Normal) ? 1.0 : 1.32, 50);
@@ -141,6 +174,10 @@ namespace TVApps.Controls
             TextArea.TranslateTo(0.0, (size == IconSize.Normal) ? 0.0 : 64.93, 50);
         }
 
+        /// <summary>
+        /// Shows option menu
+        /// </summary>
+        /// <param name="isShow">A flag indicates whether the option menu should be showed or not</param>
         public void ShowOptionMenu(bool isShow)
         {
             ButtonImage.TranslateTo(0, (isShow) ? -208.7 : 0, 100);
@@ -149,7 +186,12 @@ namespace TVApps.Controls
             OptionMenuArea.TranslateTo(0, (isShow) ? -333.91 : 0, 100);
         }
 
-        private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
+        /// <summary>
+        /// Handles button title Property Changed event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occurred when property of ButtonTitle is changed</param>
+        private void ButtonTitlePropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "Width")
             {
@@ -157,11 +199,21 @@ namespace TVApps.Controls
             }
         }
 
+        /// <summary>
+        /// Handles Button Clicked event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occurred when button is clicked</param>
         private void OnClicked(object sender, EventArgs e)
         {
             OnClickedCommand?.Execute("");
         }
 
+        /// <summary>
+        /// Handles Button Focused event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occurred when button is focused</param>
         private void OnFocused(object sender, EventArgs e)
         {
             IsFocused = true;
@@ -182,6 +234,11 @@ namespace TVApps.Controls
             }
         }
 
+        /// <summary>
+        /// Handles Button Unfocused event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occured when button is unfocused</param>
         private void OnUnFocused(object sender, EventArgs e)
         {
             IsFocused = false;
index e47ab1bd8a0056ebab8c2f2786c22dc920028117..b5879cac0822638b5d3a4b2ab672502572e07dc5 100644 (file)
  * limitations under the License.
  */
 
-using System.Linq;
-
 using Xamarin.Forms;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
 using System.ComponentModel;
 using LibTVRefCommonPortable.DataModels;
-using LibTVRefCommonPortable.Utils;
 using System.Collections.Generic;
 using System;
 using System.Threading.Tasks;
@@ -33,6 +28,9 @@ namespace TVApps.Controls
     /// </summary>
     public partial class AppListView : ScrollView
     {
+        /// <summary>
+        /// The property for source of list items
+        /// </summary>
         public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<ShortcutInfo>), typeof(AppListView), default(IEnumerable<ShortcutInfo>));
         public IEnumerable<ShortcutInfo> ItemsSource
         {
@@ -40,6 +38,9 @@ namespace TVApps.Controls
             set { SetValue(ItemsSourceProperty, value); }
         }
 
+        /// <summary>
+        /// The property for template of list items
+        /// </summary>
         public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create("ItemTemplate", typeof(DataTemplate), typeof(AppListView), default(DataTemplate));
         public DataTemplate ItemTemplate
         {
@@ -47,8 +48,14 @@ namespace TVApps.Controls
             set { SetValue(ItemTemplateProperty, value); }
         }
 
+        /// <summary>
+        /// The total count of items in list
+        /// </summary>
         private int AppCount;
 
+        /// <summary>
+        /// Checks first item in list is focused
+        /// </summary>
         public bool IsFirstItemFocused
         {
             get
@@ -62,22 +69,33 @@ namespace TVApps.Controls
             }
         }
 
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public AppListView()
         {
             InitializeComponent();
             AppCount = 0;
-            PropertyChanged += OnPropertyChange;
+            PropertyChanged += OnPropertyChanged;
         }
 
-        void OnPropertyChange(object sender, PropertyChangedEventArgs e)
+        /// <summary>
+        /// Handles AppListView Property Changed event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occured when property of AppListView is changed</param>
+        void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "ItemsSource" || e.PropertyName == "ItemTemplate")
             {
-                LoadItems();
+                CreateAppItemCells();
             }
         }
 
-        void LoadItems()
+        /// <summary>
+        /// Creates and Adds AppItemCells binded with ItemsSource
+        /// </summary>
+        void CreateAppItemCells()
         {
             AppCount = 0;
             AppUpperList.Children.Clear();
@@ -123,38 +141,46 @@ namespace TVApps.Controls
             //}
         }
 
+        /// <summary>
+        /// Scrolls the list with spacing
+        /// </summary>
+        /// <param name="index">The index of focused item cell</param>
         private async void ScrollToIndex(int index)
         {
             if (AppUpperList.Children.Count > index)
             {
                 var StartX = AppUpperList.Children[index].X;
-                var LowerBound = StartX - (240 * 6) - (16 * 7) - 56;
-                LowerBound = LowerBound > 0 ? LowerBound : 0;
-                var UpperBound = StartX - 16 - 56;
-                UpperBound = UpperBound > 0 ? UpperBound : 0;
+                var lowerScrollX = StartX - (240 * 6) - (16 * 7) - 56;
+                lowerScrollX = lowerScrollX > 0 ? lowerScrollX : 0;
+                var upperScrollX = StartX - 16 - 56;
+                upperScrollX = upperScrollX > 0 ? upperScrollX : 0;
 
                 // Is Focusable.
-                if (ScrollX >= LowerBound && ScrollX <= UpperBound)
+                if (ScrollX >= lowerScrollX && ScrollX <= upperScrollX)
                 {
                     return;
                 }
 
-                var Ldiff = Math.Abs(ScrollX - LowerBound);
-                var Rdiff = Math.Abs(ScrollX - UpperBound);
+                var lowerDistance = Math.Abs(ScrollX - lowerScrollX);
+                var upperDistance = Math.Abs(ScrollX - upperScrollX);
 
-                if (Ldiff > Rdiff)
+                if (lowerDistance > upperDistance)
                 {
                     await Task.Delay(1);
-                    await ScrollToAsync(UpperBound, 0, true);
+                    await ScrollToAsync(upperScrollX, 0, true);
                 }
                 else
                 {
                     await Task.Delay(1);
-                    await ScrollToAsync(LowerBound, 0, true);
+                    await ScrollToAsync(lowerScrollX, 0, true);
                 }
             }
         }
 
+        /// <summary>
+        /// Focusing Initialize
+        /// Focus first item in apps list
+        /// </summary>
         public void InitializeFocus()
         {
             if (AppUpperList.Children.Count > 0)
index 0b9309e1b1c6ba81950cbe3f44f6eb993c766f96..5a77a792fa8778d6aac7c222175e6aa79eca8525 100644 (file)
@@ -23,12 +23,21 @@ namespace TVApps.Controls
     /// <summary>
     /// Custom Button for TVButton to get pressed/release status
     /// </summary>
-    ///
     public partial class CustomButton : Button
     {
+        /// <summary>
+        /// The event handler for button released event
+        /// </summary>
         public EventHandler OnButtonUp;
+
+        /// <summary>
+        /// The event handler for button pressed event
+        /// </summary>
         public EventHandler OnButtonDown;
 
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public CustomButton()
         {
             InitializeComponent();
index 4d333bc0a5070a8dfbe3681685e04303295349f7..e657f4971909df59e55cb74e518af6ece9e7dd84 100644 (file)
@@ -1,8 +1,18 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+/*
+ * 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 Xamarin.Forms;
 using Xamarin.Forms.Xaml;
@@ -16,35 +26,49 @@ namespace TVApps.Controls
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class NinePatchImage : Image
     {
+        /// <summary>
+        /// The property for left border of image
+        /// </summary>
         public static readonly BindableProperty BorderLeftProperty = BindableProperty.Create("BorderLeft", typeof(int), typeof(NinePatchImage), default(int));
-        public static readonly BindableProperty BorderRightProperty = BindableProperty.Create("BorderRight", typeof(int), typeof(NinePatchImage), default(int));
-        public static readonly BindableProperty BorderTopProperty = BindableProperty.Create("BorderTop", typeof(int), typeof(NinePatchImage), default(int));
-        public static readonly BindableProperty BorderBottomProperty = BindableProperty.Create("BorderBottom", typeof(int), typeof(NinePatchImage), default(int));
-
         public int BorderLeft
         {
             get { return (int)GetValue(BorderLeftProperty); }
             set { SetValue(BorderLeftProperty, value); }
         }
 
+        /// <summary>
+        /// The property for right border of image
+        /// </summary>
+        public static readonly BindableProperty BorderRightProperty = BindableProperty.Create("BorderRight", typeof(int), typeof(NinePatchImage), default(int));
         public int BorderRight
         {
             get { return (int)GetValue(BorderRightProperty); }
             set { SetValue(BorderRightProperty, value); }
         }
 
+        /// <summary>
+        /// The property for top border of image
+        /// </summary>
+        public static readonly BindableProperty BorderTopProperty = BindableProperty.Create("BorderTop", typeof(int), typeof(NinePatchImage), default(int));
         public int BorderTop
         {
             get { return (int)GetValue(BorderTopProperty); }
             set { SetValue(BorderTopProperty, value); }
         }
 
+        /// <summary>
+        /// The property for bottom border of image
+        /// </summary>
+        public static readonly BindableProperty BorderBottomProperty = BindableProperty.Create("BorderBottom", typeof(int), typeof(NinePatchImage), default(int));
         public int BorderBottom
         {
             get { return (int)GetValue(BorderBottomProperty); }
             set { SetValue(BorderBottomProperty, value); }
         }
 
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public NinePatchImage()
         {
             InitializeComponent();
index 10594ae63ade085c58b53f2a4b90fa63fb54326f..52897908d01513ca6ae4cc610a934e68eca2a30e 100644 (file)
  * limitations under the License.
  */
 
-using LibTVRefCommonPortable.Utils;
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Input;
 using Xamarin.Forms;
-using Xamarin.Forms.Xaml;
 
 namespace TVApps.Controls
 {
@@ -31,17 +25,25 @@ namespace TVApps.Controls
     /// </summary>
     public partial class TVButton : StackLayout
     {
+        /// <summary>
+        /// The title of TVButton
+        /// </summary>
         public string Text
         {
             get { return TitleText.Text; }
             set { TitleText.Text = value; }
         }
 
+        /// <summary>
+        /// The bindable property for command
+        /// </summary>
+        /// <see cref="Command"/>
         public static readonly BindableProperty CommandProperty =
            BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(TVButton), null, BindingMode.TwoWay);
 
         /// <summary>
-        /// A command will be executed if the button is touched. </summary>
+        /// A command will be executed if the button is touched.
+        /// </summary>
         public ICommand Command
         {
             get { return (ICommand)GetValue(CommandProperty); }
@@ -49,17 +51,29 @@ namespace TVApps.Controls
         }
 
         /// <summary>
-        /// A command parameter will be passed when the Command is executed. </summary>
+        /// A command parameter will be passed when the Command is executed.
+        /// </summary>
         /// <see cref="CommandButton.Command"/>
-        public String CommandParameter
+        public string CommandParameter
         {
             get;
             set;
         }
 
-        private static String ButtonImagePressed = "btn_tizen_dropdown_line_dimmed.9.png";
-        private static String ButtonImageReleased = "btn_tizen_dropdown_line_normal.9.png";
 
+        /// <summary>
+        /// The image path for button is pressed
+        /// </summary>
+        private static readonly string ButtonImagePressed = "btn_tizen_dropdown_line_dimmed.9.png";
+
+        /// <summary>
+        /// The image path for button is released
+        /// </summary>
+        private static readonly string ButtonImageReleased = "btn_tizen_dropdown_line_normal.9.png";
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public TVButton()
         {
             InitializeComponent();
@@ -70,6 +84,11 @@ namespace TVApps.Controls
             HiddenButton.OnButtonDown += ButtonDownListener;
         }
 
+        /// <summary>
+        /// Handles Button Clicked event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occured when button is clicked</param>
         private void ButtonClickListener(object sender, EventArgs e)
         {
             // Stops playing animation
@@ -103,6 +122,11 @@ namespace TVApps.Controls
             });
         }
 
+        /// <summary>
+        /// Handles Button Focused event
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">The event that is occured when button is focused</param>
         private void ButtonFocusedListener(object sender, FocusEventArgs e)
         {
             // Stops playing animation
@@ -119,6 +143,11 @@ namespace TVApps.Controls
             length: 150);
         }
 
+        /// <summary>
+        /// Handles Button Unfocused event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occured when button is unfocused</param>
         private void ButtonUnfocusedListener(object sender, FocusEventArgs e)
         {
             // Stops playing animation
@@ -135,17 +164,34 @@ namespace TVApps.Controls
             length: 150);
         }
 
-        public void ButtonUpListener(Object sender, EventArgs e)
+        /// <summary>
+        /// Handles Button Up event
+        /// </summary>
+        /// <param name="sender">The event sender</param>
+        /// <param name="e">The event that is occured when button is released</param>
+        public void ButtonUpListener(object sender, EventArgs e)
         {
             BackgroundImage.Source = ButtonImageReleased;
             Command?.Execute(CommandParameter);
         }
 
-        public void ButtonDownListener(Object sender, EventArgs e)
+        /// <summary>
+        /// Handles Button Down event
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The event that is occured when button is pressed</param>
+        public void ButtonDownListener(object sender, EventArgs e)
         {
             BackgroundImage.Source = ButtonImagePressed;
         }
 
+        /// <summary>
+        /// Positions and Sizes the children
+        /// </summary>
+        /// <param name="x">The x position for the children</param>
+        /// <param name="y">The y position for the children</param>
+        /// <param name="width">The width for the children</param>
+        /// <param name="height">The height for the children</param>
         protected override void LayoutChildren(double x, double y, double width, double height)
         {
             base.LayoutChildren(x, y, width, height);