*/
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Input;
+using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
namespace TVMediaHub.Tizen.Controls
{
public event EventHandler<string> OnButtonUp;
public event EventHandler<string> OnButtonDown;
- public string Direction
+ public event EventHandler Clicked;
+
+ private string imgViewerPrefix = "btn_viewer_control_";
+ private string imgZoomPrefix = "ic_zoom_arrow_";
+ private string imgNormalPostFix = "_normal.png";
+ private string imgPressedPostFix = "_pressed.png";
+
+ public string Type
+ {
+ get;
+ set;
+ }
+
+ public string SubType
{
get;
set;
}
- public ICommand ChangeImageCommand
+
+ public ICommand TapGestureCommand
{
get;
set;
public void OnButtonPressed()
{
- Source = "ic_tizen_zoom_arrow_" + Direction.ToLower() + "_selected.png";
+ if (Type.Equals("Viewer"))
+ {
+ Source = imgViewerPrefix + SubType.ToLower() + imgPressedPostFix;
+ }
+ if (Type.Equals("Zoom"))
+ {
+ Source = imgZoomPrefix + SubType.ToLower() + imgPressedPostFix;
+ }
+
+ OnButtonDown?.Invoke(this, SubType);
}
public void OnButtonReleased()
{
- Source = "ic_tizen_zoom_arrow_" + Direction.ToLower() + "_normal.png";
+ if (Type.Equals("Viewer"))
+ {
+ Source = imgViewerPrefix + SubType.ToLower() + imgNormalPostFix;
+ }
+ else if (Type.Equals("Zoom"))
+ {
+ Source = imgZoomPrefix + SubType.ToLower() + imgNormalPostFix;
+ }
+
+ OnButtonUp?.Invoke(this, SubType);
}
public CustomImageButton()
{
InitializeComponent();
- ChangeImageCommand = new Command<string>((param) =>
+ TapGestureCommand = new Command(() =>
{
- if (param.Equals("keyup"))
- {
- OnButtonReleased();
- OnButtonUp?.Invoke(this, Direction);
- }
- else if (param.Equals("keydown"))
- {
- OnButtonPressed();
- OnButtonDown?.Invoke(this, Direction);
- }
+ Clicked?.Invoke(this, EventArgs.Empty);
});
}
}
* limitations under the License.
*/
-using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
-using ElmSharp;
using TVMediaHub.Tizen.Controls;
+using TVMediaHub.Tizen.Utils;
[assembly: ExportRenderer(typeof(CustomImageButton), typeof(CustomImageRenderer))]
namespace TVMediaHub.Tizen.Controls
{
base.OnElementChanged(args);
- if (Control == null ||Element == null)
+ if (Control == null || Element == null)
{
return;
}
GestureRecognizer.Attach(Control);
}
+ CustomImageButton BtnElement = Element as CustomImageButton;
+ if (BtnElement == null)
+ {
+ return;
+ }
+
GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.Start, x =>
{
- KeyDown();
+ BtnElement.OnButtonPressed();
});
+
GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.End, x =>
{
- KeyUp();
+ BtnElement.OnButtonReleased();
+ BtnElement.TapGestureCommand?.Execute(null);
});
- }
- private void KeyUp()
- {
- CustomImageButton BtnElement = Element as CustomImageButton;
- BtnElement.ChangeImageCommand.Execute("keyup");
- }
+ GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.Start, x =>
+ {
+ BtnElement.OnButtonPressed();
+ });
- private void KeyDown()
- {
- CustomImageButton BtnElement = Element as CustomImageButton;
- BtnElement.ChangeImageCommand.Execute("keydown");
+ GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.End, x =>
+ {
+ BtnElement.OnButtonReleased();
+ });
+
+ Control.RepeatEvents = true;
+ Control.SetFocus(true);
}
}
}
<Content Include="res\ic_tizen_option_menu_list_box_check_normal.png" />
<Content Include="res\ic_tizen_option_menu_list_box_check_selected.png" />
<Content Include="res\ic_tizen_play_speed_info.png" />
- <Content Include="res\ic_tizen_zoom_arrow_down_normal.png" />
- <Content Include="res\ic_tizen_zoom_arrow_down_selected.png" />
- <Content Include="res\ic_tizen_zoom_arrow_left_normal.png" />
- <Content Include="res\ic_tizen_zoom_arrow_left_selected.png" />
- <Content Include="res\ic_tizen_zoom_arrow_right_normal.png" />
- <Content Include="res\ic_tizen_zoom_arrow_right_selected.png" />
- <Content Include="res\ic_tizen_zoom_arrow_up_normal.png" />
- <Content Include="res\ic_tizen_zoom_arrow_up_selected.png" />
+ <Content Include="res\ic_zoom_arrow_down_normal.png" />
+ <Content Include="res\ic_zoom_arrow_down_pressed.png" />
+ <Content Include="res\ic_zoom_arrow_left_normal.png" />
+ <Content Include="res\ic_zoom_arrow_left_pressed.png" />
+ <Content Include="res\ic_zoom_arrow_right_normal.png" />
+ <Content Include="res\ic_zoom_arrow_right_pressed.png" />
+ <Content Include="res\ic_zoom_arrow_up_normal.png" />
+ <Content Include="res\ic_zoom_arrow_up_pressed.png" />
<Content Include="res\img_tizen_dimmed_opacity85.9.png" />
<Content Include="res\img_tizen_gradient_topbottom.9.png" />
<Content Include="res\img_tizen_media_thumbnail_gradient_focused.9.png" />
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TVMediaHub.Tizen.Views.ImageViewer"
xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
+ xmlns:Controls="clr-namespace:TVMediaHub.Tizen.Controls"
SavedRotationCommand="{Binding SavedRotationCommand}"
+ NavigationCommand="{Binding NavigationCommand}"
CurrentImage="{Binding CurrentImage}">
<RelativeLayout>
<Image x:Name="Thumbnail"
<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 Grid.Row="5" Grid.Column="1" x:Name="RotateBg" Source="btn_viewer_control_focused.png" Opacity="0"/>
- <Image Grid.Row="5" Grid.Column="1" Source="btn_viewer_control_rotate_normal.png" />
- <Button Grid.Row="5" Grid.Column="1" x:Name="RotateImage" Opacity="0"
- Clicked="RotateBtnClicked" />
+ <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 Grid.Row="5" Grid.Column="3" x:Name="ZoomBg" Source="btn_viewer_control_focused.png" Opacity="0"/>
- <Image Grid.Row="5" Grid.Column="3" Source="btn_viewer_control_zoom_normal.png" />
- <Button Grid.Row="5" Grid.Column="3" x:Name="ZoomBtn" Opacity="0" Clicked="ZoomBtnClicked" />
+ <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 Grid.Row="5" Grid.Column="5" x:Name="LeftNaviBg" Source="btn_viewer_control_focused.png" Opacity="0"/>
- <Image Grid.Row="5" Grid.Column="5" Source="btn_viewer_control_left_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="LeftNativation" Opacity="0"
- Command="{Binding NavigationCommand}"
- CommandParameter="Left"/>
+ 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 Grid.Row="5" Grid.Column="7" x:Name="RightNaviBg" Source="btn_viewer_control_focused.png" Opacity="0"/>
- <Image Grid.Row="5" Grid.Column="7" Source="btn_viewer_control_right_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="RightNativation" Opacity="0"
- Command="{Binding NavigationCommand}"
- CommandParameter="Right"/>
+ 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 Grid.Row="5" Grid.Column="9" x:Name="SlideShowBg" Source="btn_viewer_control_focused.png" Opacity="0"/>
- <Image Grid.Row="5" Grid.Column="9" Source="btn_viewer_control_video_normal.png" />
- <Button Grid.Row="5" Grid.Column="9" x:Name="SlideShowBtn" Opacity="0" Clicked="SlideShowBtnClicked" />
+ <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 Grid.Row="5" Grid.Column="11" Source="btn_viewer_control_option_normal.png" />
+ <Controls:CustomImageButton
+ x:Name="OptionImage"
+ Type="Viewer" SubType="Option"
+ Grid.Row="5" Grid.Column="11"
+ Source="btn_viewer_control_option_normal.png" />
</Grid>
</RelativeLayout>
</ContentPage>
\ No newline at end of file
set { SetValue(SavedRotationCommandProperty, value); }
}
+ public static readonly BindableProperty NavigationCommandProperty = BindableProperty.Create("NavigationCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
+ public ICommand NavigationCommand
+ {
+ get { return (ICommand)GetValue(NavigationCommandProperty); }
+ set { SetValue(NavigationCommandProperty, value); }
+ }
+
public static readonly BindableProperty CurrentImageProperty = BindableProperty.Create("CurrentImage", typeof(ImageViewerInfomation), typeof(ImageViewer), null);
public ImageViewerInfomation CurrentImage
{
private void InitializeButtonFocusImage()
{
- RotateImage.Focused += (s, e) =>
+ RotateBtn.Focused += (s, e) =>
{
RotateBg.ScaleTo(3, 250);
RotateBg.FadeTo(1, 250);
SlideShowBg.FadeTo(1, 250);
};
- RotateImage.Unfocused += (s, e) =>
+ RotateBtn.Unfocused += (s, e) =>
{
RotateBg.ScaleTo(1, 250);
RotateBg.FadeTo(0, 250);
};
}
- private async void ZoomBtnClicked(object sender, EventArgs e)
- {
- await Navigation.PushAsync(new ImageViewerZoom());
- }
-
- private async void SlideShowBtnClicked(object sender, EventArgs e)
- {
- await Navigation.PushAsync(new ImageViewerSlideShow());
- }
-
private async void RotateBtnClicked(object sender, EventArgs e)
{
if (isRotationRunning)
}
int duration = 500;
+ int rotateAngle = 90;
int currentAngle = Convert.ToInt32(Thumbnail.Rotation);
isRotationRunning = true;
#pragma warning disable CS4014
- Thumbnail.ScaleTo((((currentAngle + 90) == 90 || (currentAngle + 90) == 270) ? 0.56 : 1), Convert.ToUInt32(duration), Easing.CubicInOut);
+ Thumbnail.ScaleTo((((currentAngle + rotateAngle) == 90 || (currentAngle + rotateAngle) == 270) ? (double)((double)Thumbnail.Height / (double)Thumbnail.Width) : 1), Convert.ToUInt32(duration), Easing.CubicInOut);
#pragma warning restore CS4014
- await Thumbnail.RotateTo(Thumbnail.Rotation + 90, Convert.ToUInt32(duration), Easing.CubicInOut);
+ await Thumbnail.RotateTo(Thumbnail.Rotation + rotateAngle, Convert.ToUInt32(duration), Easing.CubicInOut);
Thumbnail.Rotation = (Thumbnail.Rotation == 360) ? 0 : Thumbnail.Rotation;
SavedRotationCommand?.Execute(Thumbnail.Rotation);
isRotationRunning = false;
}
+ private async void ZoomBtnClicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new ImageViewerZoom());
+ }
+
+ private void LeftBtnClicked(object sender, EventArgs e)
+ {
+ NavigationCommand?.Execute("Left");
+ }
+
+ private void RightBtnClicked(object sender, EventArgs e)
+ {
+ NavigationCommand?.Execute("Right");
+ }
+
+ private async void SlideShowBtnClicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new ImageViewerSlideShow());
+ }
+
protected override void LayoutChildren(double x, double y, double width, double height)
{
base.LayoutChildren(x, y, width, height);
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}" >
<Controls:CustomImageButton x:Name="UpButton"
- Direction="Up"
+ 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_tizen_zoom_arrow_up_normal.png" />
+ Source="ic_zoom_arrow_up_normal.png" />
<Controls:CustomImageButton x:Name="DownButton"
- Direction="Down"
+ 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_tizen_zoom_arrow_down_normal.png" />
+ Source="ic_zoom_arrow_down_normal.png" />
<Controls:CustomImageButton x:Name="LeftButton"
- Direction="Left"
+ 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_tizen_zoom_arrow_left_normal.png" />
+ Source="ic_zoom_arrow_left_normal.png" />
<Controls:CustomImageButton x:Name="RightButton"
- Direction="Right"
+ 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_tizen_zoom_arrow_right_normal.png" />
+ 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}"
int currentAngle = Convert.ToInt32(SavedRotation);
imgOrientation = (ElmSharp.ImageOrientation)Enum.ToObject(typeof(ElmSharp.ImageOrientation), currentAngle / 90);
- CurrentImage.Scale = (currentAngle == 90 || currentAngle == 270) ? 0.56 : 1;
+ CurrentImage.Scale = (currentAngle == 90 || currentAngle == 270) ? (double)((double)App.MainWindow.Geometry.Height / (double)App.MainWindow.Geometry.Width) : 1;
CurrentImage.Aspect = (currentAngle == 90 || currentAngle == 270) ? Aspect.AspectFill : Aspect.AspectFit;
CurrentImage.Rotation = SavedRotation;
}