*/
using System;
-using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
namespace TVMediaHub.Tizen.Controls
/// An Event Handler to notify if the button is clicked
/// </summary>
public event EventHandler Clicked;
+
/// <summary>
/// A value of effect duration
/// </summary>
<?xml version="1.0" encoding="utf-8" ?>
<Image xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="TVMediaHub.Tizen.Controls.CustomImageButton" >
+ x:Class="TVMediaHub.Tizen.Controls.ZoomNaviButton" >
</Image>
\ No newline at end of file
/// <summary>
/// A custom image for displaying the buttons of image viewer
/// </summary>
- public partial class CustomImageButton : Image
+ public partial class ZoomNaviButton : Image
{
+ /// <summary>
+ /// An event handler to notify if the button is up
+ /// </summary>
public event EventHandler<string> OnButtonUp;
+
+ /// <summary>
+ /// An event handler to notify if the button is down
+ /// </summary>
public event EventHandler<string> OnButtonDown;
+
+ /// <summary>
+ /// An event handler to notify if the button is clicked
+ /// </summary>
public event EventHandler Clicked;
- private string imgViewerPrefix = "btn_viewer_control_";
+ /// <summary>
+ /// A prefix of the navigation button image
+ /// </summary>
private string imgZoomPrefix = "ic_zoom_arrow_";
+
+ /// <summary>
+ /// A postfix of the navigation button image on normal status
+ /// </summary>
private string imgNormalPostFix = "_normal.png";
- private string imgPressedPostFix = "_pressed.png";
/// <summary>
- /// Gets or sets the button type
+ /// A postfix of the navigation button image on pressed status
/// </summary>
- public string Type
- {
- get;
- set;
- }
+ private string imgPressedPostFix = "_pressed.png";
/// <summary>
- /// Gets or sets the button subtype
+ /// Gets or sets the button type
/// </summary>
- public string SubType
+ public string Type
{
get;
set;
/// </summary>
public void OnButtonPressed()
{
- if (Type.Equals("Viewer"))
- {
- Source = imgViewerPrefix + SubType.ToLower() + imgPressedPostFix;
- }
+ Source = imgZoomPrefix + Type.ToLower() + imgPressedPostFix;
- if (Type.Equals("Zoom"))
- {
- Source = imgZoomPrefix + SubType.ToLower() + imgPressedPostFix;
- }
-
- OnButtonDown?.Invoke(this, SubType);
+ OnButtonDown?.Invoke(this, Type);
}
/// <summary>
/// </summary>
public void OnButtonReleased()
{
- if (Type.Equals("Viewer"))
- {
- Source = imgViewerPrefix + SubType.ToLower() + imgNormalPostFix;
- }
- else if (Type.Equals("Zoom"))
- {
- Source = imgZoomPrefix + SubType.ToLower() + imgNormalPostFix;
- }
+ Source = imgZoomPrefix + Type.ToLower() + imgNormalPostFix;
- OnButtonUp?.Invoke(this, SubType);
+ OnButtonUp?.Invoke(this, Type);
}
/// <summary>
/// A constructor
/// Implements the TapGestureCommand
/// </summary>
- public CustomImageButton()
+ public ZoomNaviButton()
{
InitializeComponent();
using Xamarin.Forms.Platform.Tizen;
using TVMediaHub.Tizen.Controls;
-[assembly: ExportRenderer(typeof(CustomImageButton), typeof(CustomImageRenderer))]
+[assembly: ExportRenderer(typeof(ZoomNaviButton), typeof(ZoomNaviButtonRenderer))]
namespace TVMediaHub.Tizen.Controls
{
/// <summary>
/// A custom renderer for making custom image button.
/// </summary>
- public class CustomImageRenderer : ImageRenderer
+ public class ZoomNaviButtonRenderer : ImageRenderer
{
private ElmSharp.GestureLayer GestureRecognizer;
/// <summary>
- /// Creates GestureRecognizer and sets callbacks for tap and longtap event when Element is changed.
+ /// Creates GestureRecognizer and sets callbacks for tap and long tap event when Element is changed.
/// </summary>
/// <param name="args">An image element property changed event's argument</param>
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Image> args)
GestureRecognizer.Attach(Control);
}
- CustomImageButton BtnElement = Element as CustomImageButton;
+ ZoomNaviButton BtnElement = Element as ZoomNaviButton;
if (BtnElement == null)
{
return;
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}" >
- <Controls:CustomImageButton x:Name="UpButton"
- Type="Zoom"
- SubType="Up"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.037037}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.478125}"
- Source="ic_zoom_arrow_up_normal.png" />
- <Controls:CustomImageButton x:Name="DownButton"
- Type="Zoom"
- SubType="Down"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.885185}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.478125}"
- Source="ic_zoom_arrow_down_normal.png" />
- <Controls:CustomImageButton x:Name="LeftButton"
- Type="Zoom"
- SubType="Left"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.461111}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.02083}"
- Source="ic_zoom_arrow_left_normal.png" />
- <Controls:CustomImageButton x:Name="RightButton"
- Type="Zoom"
- SubType="Right"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.461111}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.9354167}"
- Source="ic_zoom_arrow_right_normal.png" />
+ <Controls:ZoomNaviButton x:Name="UpButton"
+ Type="Up"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.037037}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.478125}"
+ Source="ic_zoom_arrow_up_normal.png" />
+ <Controls:ZoomNaviButton x:Name="DownButton"
+ Type="Down"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.885185}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.478125}"
+ Source="ic_zoom_arrow_down_normal.png" />
+ <Controls:ZoomNaviButton x:Name="LeftButton"
+ Type="Left"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.461111}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.02083}"
+ Source="ic_zoom_arrow_left_normal.png" />
+ <Controls:ZoomNaviButton x:Name="RightButton"
+ Type="Right"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.077778}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.04375}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.461111}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.9354167}"
+ Source="ic_zoom_arrow_right_normal.png" />
<Grid x:Name="BackKeyInfo"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Height, Factor=0.037037}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ZoomGrid, Property=Width, Factor=0.059375}"
private ElmSharp.ImageOrientation imgOrientation = ElmSharp.ImageOrientation.None;
/// <summary>
- /// The background thumbnail for the minimap
+ /// The background thumbnail for the mini map
/// </summary>
private ElmSharp.Rectangle backgroundThumbnail;
/// <summary>
- /// The thumbnail image for the minimap
+ /// The thumbnail image for the mini map
/// </summary>
private ElmSharp.Image thumbnailImg;
/// <summary>
- /// The dim image for the minimap
+ /// The dim image for the mini map
/// </summary>
private ElmSharp.Image thumbnailDim;
/// <summary>
- /// The clipping image for the minimap
+ /// The clipping image for the mini map
/// </summary>
private ElmSharp.Image clippingImg;
/// <summary>
- /// The clipper for the minimap
+ /// The clipper for the mini map
/// </summary>
private ElmSharp.Rectangle clipper;
/// <summary>
- /// The clipper border image for the minimap
+ /// The clipper border image for the mini map
/// </summary>
private ElmSharp.Image clipperBorder;
/// </summary>
protected override void InitializePage()
{
- /// Grabs the hw keys to move the given image
+ /// Grabs the hardware keys to move the given image
GrabMoveKeys();
}
/// <summary>
/// A method for finalizing page when the page is disappeared
/// Ungrabs move keys of the remote controller
- /// Releases resources of the minimap
+ /// Releases resources of the mini map
/// </summary>
protected override void FinalizePage()
{
}
/// <summary>
- /// Ungrab move keys of the remote controller
+ /// Ungrabs move keys of the remote controller
/// </summary>
private void UngrabMoveKeys()
{
int direction = MoveDirection.FindIndex(x => x.Equals(e.KeyName));
object[] buttons = new object[4] { UpButton, DownButton, LeftButton, RightButton };
- (buttons[direction] as CustomImageButton).OnButtonReleased();
+ (buttons[direction] as ZoomNaviButton).OnButtonReleased();
}
/// <summary>
return;
}
- MoveCurrentImage(e.KeyName);
-
int direction = MoveDirection.FindIndex(x => x.Equals(e.KeyName));
object[] buttons = new object[4] { UpButton, DownButton, LeftButton, RightButton };
- (buttons[direction] as CustomImageButton).OnButtonPressed();
+ (buttons[direction] as ZoomNaviButton).OnButtonPressed();
+ }
+
+ /// <summary>
+ /// Sets the navigation buttons to be normal
+ /// </summary>
+ private void SetNaviButtonNormal()
+ {
+ if (clipper == null)
+ {
+ return;
+ }
+
+ if (clipper.Geometry.Y != thumbnailDim.Geometry.Y)
+ {
+ UpButton.Opacity = 1.0;
+ }
+
+ if ((clipper.Geometry.Y + clipper.Geometry.Height) != (thumbnailDim.Geometry.Y + thumbnailDim.Geometry.Height))
+ {
+ DownButton.Opacity = 1.0;
+ }
+
+ if (clipper.Geometry.X != thumbnailDim.Geometry.X)
+ {
+ LeftButton.Opacity = 1.0;
+ }
+
+ if ((clipper.Geometry.X + clipper.Geometry.Width) != (thumbnailDim.Geometry.X + thumbnailDim.Geometry.Width))
+ {
+ RightButton.Opacity = 1.0;
+ }
}
/// <summary>
- /// Moves the current image and the clipper of the minimap
+ /// Moves the current image and the clipper of the mini map
/// </summary>
/// <param name="direction">The direction to move</param>
private void MoveCurrentImage(string direction)
clipper.Move(clipper.Geometry.X, thumbnailDim.Geometry.Y);
CurrentImage.TranslateTo(CurrentImage.TranslationX, CurrentImage.Y, Convert.ToUInt32(moveDuration), Easing.CubicOut);
+ UpButton.Opacity = 0.2;
+
return;
}
- ElmSharp.EcoreAnimator.AddAmimator(delegate()
+ ElmSharp.EcoreAnimator.AddAmimator(delegate ()
{
- clipper.Move(clipper.Geometry.X, clipper.Geometry.Y - 1);
+ clipper.Move(clipper.Geometry.X, clipper.Geometry.Y - 2);
if (clipper.Geometry.Y <= toY)
{
clipper.Move(clipper.Geometry.X, toY);
+ SetNaviButtonNormal();
+
return false;
}
clipper.Move(clipper.Geometry.X, (thumbnailDim.Geometry.Y + thumbnailDim.Geometry.Height) - clipper.Geometry.Height);
CurrentImage.TranslateTo(CurrentImage.TranslationX, -(CurrentImage.Height - App.MainWindow.Geometry.Height), Convert.ToUInt32(moveDuration), Easing.CubicOut);
+ DownButton.Opacity = 0.2;
+
return;
}
- ElmSharp.EcoreAnimator.AddAmimator(delegate()
+ ElmSharp.EcoreAnimator.AddAmimator(delegate ()
{
- clipper.Move(clipper.Geometry.X, clipper.Geometry.Y + 1);
+ clipper.Move(clipper.Geometry.X, clipper.Geometry.Y + 2);
if (clipper.Geometry.Y >= toY)
{
clipper.Move(clipper.Geometry.X, toY);
+ SetNaviButtonNormal();
+
return false;
}
clipper.Move(thumbnailDim.Geometry.X, clipper.Geometry.Y);
CurrentImage.TranslateTo(CurrentImage.X, CurrentImage.TranslationY, Convert.ToUInt32(moveDuration), Easing.CubicOut);
+ LeftButton.Opacity = 0.2;
+
return;
}
- ElmSharp.EcoreAnimator.AddAmimator(delegate()
+ ElmSharp.EcoreAnimator.AddAmimator(delegate ()
{
- clipper.Move(clipper.Geometry.X - 1, clipper.Geometry.Y);
+ clipper.Move(clipper.Geometry.X - 2, clipper.Geometry.Y);
if (clipper.Geometry.X <= toX)
{
clipper.Move(toX, clipper.Geometry.Y);
+ SetNaviButtonNormal();
+
return false;
}
clipper.Move((thumbnailDim.Geometry.X + thumbnailDim.Geometry.Width) - clipper.Geometry.Width, clipper.Geometry.Y);
CurrentImage.TranslateTo(-(CurrentImage.Width - App.MainWindow.Geometry.Width), CurrentImage.TranslationY, Convert.ToUInt32(moveDuration), Easing.CubicOut);
+ RightButton.Opacity = 0.2;
+
return;
}
- ElmSharp.EcoreAnimator.AddAmimator(delegate()
+ ElmSharp.EcoreAnimator.AddAmimator(delegate ()
{
- clipper.Move(clipper.Geometry.X + 1, clipper.Geometry.Y);
+ clipper.Move(clipper.Geometry.X + 2, clipper.Geometry.Y);
if (clipper.Geometry.X >= toX)
{
clipper.Move(toX, clipper.Geometry.Y);
+ SetNaviButtonNormal();
+
return false;
}
}
/// <summary>
- /// Creates the minimap
+ /// Creates the mini map
/// </summary>
private void CreateMiniMap()
{
Constraint.Constant(640), /// Width
Constraint.Constant(430)); /// Height
- /// create the shadow of the mini map
+ /// Create the shadow of the mini map
var backgroundShadow = new NinePatch
{
Source = "img_zoom_minimap_shadow.9.png",
object[] buttons = new object[4] { UpButton, DownButton, LeftButton, RightButton };
foreach (object button in buttons)
{
- (button as CustomImageButton).OnButtonDown += (s, e) =>
+ (button as ZoomNaviButton).OnButtonDown += (s, e) =>
{
- DbgPort.D("'" + e + "' is pressed");
+ DbgPort.D("[" + e + "] is pressed");
MoveCurrentImage(e as string);
};