using Tizen = Xamarin.Forms.PlatformConfiguration.Tizen;
/// <summary>
- /// A custom ContentPage for displaying Image viewer
+ /// A custom ContentPage for displaying the image viewer
/// </summary>
public partial class ImageViewer : ContentPage
{
AUTO,
};
+ /// <summary>
+ /// The value for the dim effect
+ /// </summary>
private static int gradientDimEffectTime = 667;
+ /// <summary>
+ /// The value for the dicrention of the navigation key
+ /// </summary>
NaviDirection naviDirection = default(NaviDirection);
+ /// <summary>
+ /// A flag whether rotation animation is running or not
+ /// </summary>
private bool isRotationRunning = false;
+
+ /// <summary>
+ /// A flag whether option popup is showing
+ /// </summary>
private bool isOptionPopupShowing = false;
+
+ /// <summary>
+ /// A flag whether speed option popup is showing
+ /// </summary>
private bool isSpeedOptionPopupShowing = false;
+
+ /// <summary>
+ /// A flag whether effect option popup is showing
+ /// </summary>
private bool isEffectOptionPopupShowing = false;
+
+ /// <summary>
+ /// A flag whether image viewer is first launching
+ /// </summary>
private bool isFirstLaunching = true;
+
+ /// <summary>
+ /// A flag whether navigation is running
+ /// </summary>
private bool isNaviRunning = false;
+ /// <summary>
+ /// An instance for the option popup
+ /// </summary>
private ContextPopup optionPopup = null;
+
+ /// <summary>
+ /// An instance for the speed option popup
+ /// </summary>
private ContextPopup speedOptionPopup = null;
+
+ /// <summary>
+ /// An instance for the effect option popup
+ /// </summary>
private ContextPopup effectOptionPopup = null;
+ /// <summary>
+ /// An instance for the previous content
+ /// </summary>
private ImageViewerInfomation prevContent = null;
+ /// <summary>
+ /// A key name list of the remote controller
+ /// </summary>
private string[] remoteKeys = new string[] { "Up", "Down", "Left", "Right", "XF86Menu" };
+
+ /// <summary>
+ /// The timer to handle the control area
+ /// </summary>
private IntPtr timer = default(IntPtr);
+
+ /// <summary>
+ /// The interval of the timer
+ /// </summary>
private double timerInterval = 5.0;
/// <summary>
/// Identifies the SavedRotationCommand bindable property
/// </summary>
public static readonly BindableProperty SavedRotationCommandProperty = BindableProperty.Create("SavedRotationCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
+
/// <summary>
/// Gets or sets SavedRotationCommand
/// </summary>
/// Identifies the NavigationCommand bindable property
/// </summary>
public static readonly BindableProperty NavigationCommandProperty = BindableProperty.Create("NavigationCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
+
/// <summary>
/// Gets or sets NavigationCommand
/// </summary>
/// Identifies the SetSlideShowSpeedCommand bindable property
/// </summary>
public static readonly BindableProperty SetSlideShowSpeedCommandProperty = BindableProperty.Create("SetSlideShowSpeedCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
+
/// <summary>
/// Gets or sets SetSlideShowSpeedCommand
/// </summary>
/// Identifies the SetSlideShowEffectCommand bindable property
/// </summary>
public static readonly BindableProperty SetSlideShowEffectCommandProperty = BindableProperty.Create("SetSlideShowEffectCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
+
/// <summary>
/// Gets or sets SetSlideShowEffectCommand
/// </summary>
/// Identifies the CurrentImage bindable property
/// </summary>
public static readonly BindableProperty CurrentImageProperty = BindableProperty.Create("CurrentImage", typeof(ImageViewerInfomation), typeof(ImageViewer), null);
+
/// <summary>
/// Gets or sets CurrentImage
/// </summary>
}
/// <summary>
- /// A method for grabbing remote control keys
+ /// Grabs the key of the remote controller
/// </summary>
private void GrabRemoteKeys()
{
}
/// <summary>
- /// A method for ungrabbing remote control keys
+ /// Ungrabs the key of the remote controller
/// </summary>
private void UngrabRemoteKeys()
{
}
/// <summary>
- /// A method will be called when application receives KeyDown event
+ /// KeyDown will be triggered when key is pressed down
/// </summary>
- /// <param name="sender">The source of the event</param>
- /// <param name="e">An EvasKey event's argument</param>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">The information about the event</param>
private void RemoteKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
SetControlAreaState(ControlAreaState.AUTO);
}
/// <summary>
- /// A method for initializing timer
+ /// Initialize the timer
/// </summary>
private void InitializeTimer()
{
/// </summary>
public partial class ImageViewerSlideShow : ContentPageEx
{
+ /// <summary>
+ /// A list of the image information to be shown
+ /// </summary>
private List<ImageViewerInfomation> imageList = new List<ImageViewerInfomation>();
+ /// <summary>
+ /// A flag whether the back key is pressed or not
+ /// </summary>
private static bool isBackKeyPressed = false;
/// Identifies the ItemsSource bindable property
/// </summary>
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<ImageViewerInfomation>), typeof(ImageViewerSlideShow), null);
+
/// <summary>
/// Gets or set ItemSource to display slide show
/// </summary>
/// Identifies the Speed bindable property
/// </summary>
public static readonly BindableProperty SpeedProperty = BindableProperty.Create("Speed", typeof(SlideShowSpeed), typeof(ImageViewerSlideShow), SlideShowSpeed.Normal);
+
/// <summary>
/// Gets or set Speed
/// </summary>
/// Identifies the Effect bindable property
/// </summary>
public static readonly BindableProperty EffectProperty = BindableProperty.Create("Effect", typeof(SlideShowEffect), typeof(ImageViewerSlideShow), SlideShowEffect.Dissolve);
+
/// <summary>
/// Gets or set Effect
/// </summary>
/// Identifies the CurrentImage bindable property
/// </summary>
public static readonly BindableProperty CurrentImageProperty = BindableProperty.Create("CurrentImage", typeof(ImageViewerInfomation), typeof(ImageViewerSlideShow), null);
+
/// <summary>
/// Gets or set CurrentImage
/// </summary>
}
/// <summary>
- /// A method for initializing page
+ /// A method for initializing page when the page is appeared
/// </summary>
protected override void InitializePage()
{
}
/// <summary>
- /// A method for finalizing page
+ /// A method for finalizing page when the page is disappeared
/// </summary>
protected override void FinalizePage()
{
}
}
+ /// <summary>
+ /// A method for running hide animation
+ /// </summary>
public override void RunHideAnimation()
{
}
+ /// <summary>
+ /// A method for running show animation
+ /// </summary>
public override void RunShowAnimation()
{
}
using Tizen.Xamarin.Forms.Extension;
using TVMediaHub.Tizen.Utils;
using System.IO;
-using Tizen;
using TVMediaHub.Tizen.Controls;
using System.Collections.Generic;
using System;
namespace TVMediaHub.Tizen.Views
{
/// <summary>
- /// @TODO: Comment
+ /// A custom ContentPage for the image viewer zoom mode
/// </summary>
public partial class ImageViewerZoom : ContentPageEx
{
+ /// <summary>
+ /// A list of the move direction
+ /// </summary>
private static List<string> MoveDirection = new List<string> { "Up", "Down", "Left", "Right" };
- //TODO: need to check the move size
+ /// <summary>
+ /// The value to move
+ /// </summary>
private static int clipperMoveGap = 10;
+
+ /// <summary>
+ /// The value to zoom in
+ /// </summary>
private static double zoomRatio = 1.5;
+
+ /// <summary>
+ /// The value to check the orientation of the current image
+ /// </summary>
private ElmSharp.ImageOrientation imgOrientation = ElmSharp.ImageOrientation.None;
+ /// <summary>
+ /// The background thumbnail for the minimap
+ /// </summary>
private ElmSharp.Rectangle backgroundThumbnail;
+
+ /// <summary>
+ /// The thumbnail image for the minimap
+ /// </summary>
private ElmSharp.Image thumbnailImg;
+
+ /// <summary>
+ /// The dim image for the minimap
+ /// </summary>
private ElmSharp.Image thumbnailDim;
+
+ /// <summary>
+ /// The clipping image for the minimap
+ /// </summary>
private ElmSharp.Image clippingImg;
+
+ /// <summary>
+ /// The clipper for the minimap
+ /// </summary>
private ElmSharp.Rectangle clipper;
+
+ /// <summary>
+ /// The clipper border image for the minimap
+ /// </summary>
private ElmSharp.Image clipperBorder;
+ /// <summary>
+ /// Identifies the SavedRotation bindable property
+ /// </summary>
public static readonly BindableProperty SavedRotationProperty = BindableProperty.Create("SavedRotation", typeof(double), typeof(ImageViewerZoom), default(double));
+
+ /// <summary>
+ /// Gets or sets SavedRotation
+ /// </summary>
public double SavedRotation
{
get { return (double)GetValue(SavedRotationProperty); }
set { SetValue(SavedRotationProperty, value); }
}
+ /// <summary>
+ /// Identifies the ThumbnailPath bindable property
+ /// </summary>
public static readonly BindableProperty ThumbnailPathProperty = BindableProperty.Create("ThumbnailPath", typeof(string), typeof(ImageViewerZoom), default(string));
+
+ /// <summary>
+ /// Gets or sets the ThumbnailPath
+ /// </summary>
public string ThumbnailPath
{
get { return (string)GetValue(ThumbnailPathProperty); }
set { SetValue(ThumbnailPathProperty, value); }
}
+ /// <summary>
+ /// A constructor
+ /// </summary>
public ImageViewerZoom()
{
BindingContext = ImageTabViewModelLocator.ViewModel;
};
}
+ /// <summary>
+ /// A method for initializing page when the page is appeared
+ /// Grabs move keys of the remote controller
+ /// </summary>
protected override void InitializePage()
{
/// Grabs the hw 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
+ /// </summary>
protected override void FinalizePage()
{
UngrabMoveKeys();
}
/// <summary>
- /// Grabs the hw keys to move the given image
+ /// Grabs move keys of the remote controller to move the given image
/// </summary>
private void GrabMoveKeys()
{
}
/// <summary>
- /// Ungrab the hw keys
+ /// Ungrab move keys of the remote controller
/// </summary>
private void UngrabMoveKeys()
{
}
}
+ /// <summary>
+ /// KeyUp will be triggered when key is loose
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">The information about the event</param>
private void MoveKeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
DbgPort.D("[ZoomMode] key up : " + e.KeyName);
(buttons[direction] as CustomImageButton).OnButtonReleased();
}
+ /// <summary>
+ /// KeyDown will be triggered when key is pressed down
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">The information about the event</param>
private void MoveKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
DbgPort.D("[ZoomMode] key down : " + e.KeyName);
(buttons[direction] as CustomImageButton).OnButtonPressed();
}
+ /// <summary>
+ /// Moves the current image and the clipper of the minimap
+ /// </summary>
+ /// <param name="direction">The direction to move</param>
private void MoveCurrentImage(string direction)
{
int moveDuration = 350;
}
}
+ /// <summary>
+ /// Sets the current image
+ /// </summary>
private void SetCurrentImage()
{
CurrentImage.WidthRequest = App.MainWindow.Geometry.Width * zoomRatio;
CurrentImage.Rotation = SavedRotation;
}
+ /// <summary>
+ /// Creates the minimap
+ /// </summary>
private void CreateMiniMap()
{
Grid miniMap = new Grid()
}
}
+ /// <summary>
+ /// Positions and sizes the children of a Layout.
+ /// </summary>
+ /// <param name="x">A value representing the x coordinate of the child region bounding box.</param>
+ /// <param name="y">A value representing the y coordinate of the child region bounding box.</param>
+ /// <param name="width">A value representing the width of the child region bounding box.</param>
+ /// <param name="height">A value representing the height of the child region bounding box.</param>
protected override void LayoutChildren(double x, double y, double width, double height)
{
base.LayoutChildren(x, y, width, height);
GradientDim.WidthRequest = width;
}
+ /// <summary>
+ /// A method for running hide animation
+ /// </summary>
public override void RunHideAnimation()
{
}
+ /// <summary>
+ /// A method for running show animation
+ /// </summary>
public override void RunShowAnimation()
{
}
using Tizen = Xamarin.Forms.PlatformConfiguration.Tizen;
/// <summary>
- /// @TODO: Comment
+ /// A custom ContentPage for displaying the simple image viewer
/// </summary>
public partial class SimpleImageViewer : ContentPageEx
{
+ /// <summary>
+ /// An enumeration for ControlAreaState
+ /// </summary>
enum ControlAreaState
{
SHOW = 0,
AUTO,
};
+ /// <summary>
+ /// A flag whether rotation animation is running or not
+ /// </summary>
private bool isRotationRunning;
+
+ /// <summary>
+ /// A flag whether option popup is showing
+ /// </summary>
private bool isOptionPopupShowing;
+
+ /// <summary>
+ /// A flag whether speed option popup is showing
+ /// </summary>
private bool isSpeedOptionPopupShowing;
+
+ /// <summary>
+ /// A flag whether effect option popup is showing
+ /// </summary>
private bool isEffectOptionPopupShowing;
+ /// <summary>
+ /// An instance for the option popup
+ /// </summary>
private ContextPopup optionPopup;
+
+ /// <summary>
+ /// An instance for the speed option popup
+ /// </summary>
private ContextPopup speedOptionPopup;
+
+ /// <summary>
+ /// An instance for the effect option popup
+ /// </summary>
private ContextPopup effectOptionPopup;
+ /// <summary>
+ /// A key name list of the remote controller
+ /// </summary>
private string[] remoteKeys = new string[] { "Up", "Down", "Left", "Right", "XF86Menu" };
+
+ /// <summary>
+ /// The timer to handle the control area
+ /// </summary>
private IntPtr timer = default(IntPtr);
+
+ /// <summary>
+ /// The interval of the timer
+ /// </summary>
private double timerInterval = 5.0;
+ /// <summary>
+ /// Identifies the SavedRotationCommand bindable property
+ /// </summary>
public static readonly BindableProperty SavedRotationCommandProperty = BindableProperty.Create("SavedRotationCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SavedRotationCommand
+ /// </summary>
public ICommand SavedRotationCommand
{
get { return (ICommand)GetValue(SavedRotationCommandProperty); }
set { SetValue(SavedRotationCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the NavigationCommand bindable property
+ /// </summary>
public static readonly BindableProperty NavigationCommandProperty = BindableProperty.Create("NavigationCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets NavigationCommand
+ /// </summary>
public ICommand NavigationCommand
{
get { return (ICommand)GetValue(NavigationCommandProperty); }
set { SetValue(NavigationCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the SetSlideShowSpeedCommand bindable property
+ /// </summary>
public static readonly BindableProperty SetSlideShowSpeedCommandProperty = BindableProperty.Create("SetSlideShowSpeedCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SetSlideShowSpeedCommand
+ /// </summary>
public ICommand SetSlideShowSpeedCommand
{
get { return (ICommand)GetValue(SetSlideShowSpeedCommandProperty); }
set { SetValue(SetSlideShowSpeedCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the SetSlideShowEffectCommand bindable property
+ /// </summary>
public static readonly BindableProperty SetSlideShowEffectCommandProperty = BindableProperty.Create("SetSlideShowEffectCommand", typeof(ICommand), typeof(SimpleImageViewer), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SetSlideShowEffectCommand
+ /// </summary>
public ICommand SetSlideShowEffectCommand
{
get { return (ICommand)GetValue(SetSlideShowEffectCommandProperty); }
set { SetValue(SetSlideShowEffectCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the CurrentImage bindable property
+ /// </summary>
public static readonly BindableProperty CurrentImageProperty = BindableProperty.Create("CurrentImage", typeof(ImageViewerInfomation), typeof(SimpleImageViewer), null);
+
+ /// <summary>
+ /// Gets or sets CurrentImage
+ /// </summary>
public ImageViewerInfomation CurrentImage
{
get { return (ImageViewerInfomation)GetValue(CurrentImageProperty); }
set { SetValue(CurrentImageProperty, value); }
}
+ /// <summary>
+ /// A constructor
+ /// </summary>
public SimpleImageViewer()
{
BindingContext = ImageTabViewModelLocator.ViewModel;
};
}
+ /// <summary>
+ /// Grabs the key of the remote controller
+ /// </summary>
private void GrabRemoteKeys()
{
foreach (var key in remoteKeys)
App.MainWindow.KeyDown += RemoteKeyDownListener;
}
+ /// <summary>
+ /// Ungrabs the key of the remote controller
+ /// </summary>
private void UngrabRemoteKeys()
{
App.MainWindow.KeyDown -= RemoteKeyDownListener;
}
}
+ /// <summary>
+ /// KeyDown will be triggered when key is pressed down
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">The information about the event</param>
private void RemoteKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
SetControlAreaState(ControlAreaState.AUTO);
}
+ /// <summary>
+ /// A method for changing control area according to ControlAreaState
+ /// </summary>
+ /// <param name="state">A current ControlAreaState</param>
private void SetControlAreaState(ControlAreaState state)
{
switch (state)
}
}
+ /// <summary>
+ /// A method for initializing current image's fields
+ /// </summary>
private void InitializeCurrentImage()
{
Thumb1.Source = CurrentImage.FilePath;
Thumb1.Rotation = CurrentImage.SavedRotation;
}
+ /// <summary>
+ /// A method for initializing several sizes
+ /// </summary>
private void InitializeSize()
{
int titleSize = SizeUtils.GetFontSize(44);
DateLabel.FontSize = dateSize;
}
+ /// <summary>
+ /// This method is called when the properties is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A propertyChanged event argument</param>
private void ImageViewerPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName.Equals("CurrentImage"))
}
}
+ /// <summary>
+ /// A method for initializing button of ImageViewer
+ /// </summary>
private void InitializeButtons()
{
MediaHubButton[] buttons = new MediaHubButton[6] { RotateBtn, ZoomBtn, LeftBtn, RightBtn, SlideShowBtn, OptionBtn };
}
}
+ /// <summary>
+ /// This method is called when Rotate button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private async void RotateBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
isRotationRunning = false;
}
+ /// <summary>
+ /// This method is called when Zoom button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private void ZoomBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
Program.TransitionTo(new ImageViewerZoom());
}
+ /// <summary>
+ /// This method is called when Left button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private void LeftBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
NavigationCommand?.Execute("Left");
}
+ /// <summary>
+ /// This method is called when Right button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private void RightBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
NavigationCommand?.Execute("Right");
}
+ /// <summary>
+ /// This method is called when Slide show button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private void SlideShowBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
Program.TransitionTo(new ImageViewerSlideShow());
}
+ /// <summary>
+ /// This method is called when Option button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
private void OptionBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
CreateOptionPopup();
}
+ /// <summary>
+ /// A method for creating option context popup
+ /// </summary>
private void CreateOptionPopup()
{
if (isOptionPopupShowing)
SetControlAreaState(ControlAreaState.SHOW);
}
+ /// <summary>
+ /// A method for creating slide show speed option context popup
+ /// </summary>
private void CreateSlideShowSpeedOptionPopup()
{
if (isSpeedOptionPopupShowing)
isSpeedOptionPopupShowing = true;
}
+ /// <summary>
+ /// A method for creating slide show effect option context popup
+ /// </summary>
private void CreateSlideShowEffectOptionPopup()
{
if (isEffectOptionPopupShowing)
isEffectOptionPopupShowing = true;
}
+ /// <summary>
+ /// Positions and sizes the children of a Layout.
+ /// </summary>
+ /// <param name="x">A value representing the x coordinate of the child region bounding box.</param>
+ /// <param name="y">A value representing the y coordinate of the child region bounding box.</param>
+ /// <param name="width">A value representing the width of the child region bounding box.</param>
+ /// <param name="height">A value representing the height of the child region bounding box.</param>
protected override void LayoutChildren(double x, double y, double width, double height)
{
base.LayoutChildren(x, y, width, height);
GradientDim.WidthRequest = width;
}
+ /// <summary>
+ /// A method for initializing page when the page is appeared
+ /// Grabs move keys of the remote controller
+ /// </summary>
protected override void InitializePage()
{
RotateBtn.MediaHubButtonBtn.On<Tizen>().SetNextFocusLeftView(RotateBtn.MediaHubButtonBtn);
GrabRemoteKeys();
}
+ /// <summary>e
+ /// A method for hiding control area when timer is over
+ /// </summary>
+ /// <returns>Always returns false</returns>
private Func<bool> HideControlAreaHandler()
{
return delegate()
};
}
+ /// <summary>
+ /// A method for finalizing page when the page is disappeared
+ /// Ungrabs move keys of the remote controller
+ /// Releases resources of the minimap
+ /// </summary>
protected override void FinalizePage()
{
UngrabRemoteKeys();
}
+ /// <summary>
+ /// A method for running hide animation
+ /// </summary>
public override void RunHideAnimation()
{
GradientDim.FadeTo(0, 667, Easing.CubicInOut);
TitleContainer.FadeTo(0, 667, Easing.CubicInOut);
}
+ /// <summary>
+ /// A method for running show animation
+ /// </summary>
public override void RunShowAnimation()
{
GradientDim.Opacity = 0;
/// KeyDown will be triggered when key is preesd down
/// </summary>
/// <param name="sender">The object that raised the event</param>
- /// <param name="e">Information about the event</param>
+ /// <param name="e">The information about the event</param>
private void RemoteKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
SetControlAreaState(ControlAreaState.AUTO);