using System;
using System.ComponentModel;
-using System.Globalization;
using System.Windows.Input;
using Xamarin.Forms;
/// </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
{
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
{
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
{
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
{
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
{
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)
{
// TODO : Change Animation (Add Pin Contents Item : Unselected)
if (IsFocused)
{
+ View.AbortAnimation("CheckedAnimation");
View.Animate("CheckedAnimation", (v) =>
{
var scale = 1.32 - (0.22) * v;
}
}
+ /// <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);
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);
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")
{
}
}
+ /// <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;
}
}
+ /// <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;
* 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;
/// </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
{
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
{
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
}
}
+ /// <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();
//}
}
+ /// <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)
/// <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();
-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;
[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();
* 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
{
/// </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); }
}
/// <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();
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
});
}
+ /// <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
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
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);