*/
using System;
+using System.Collections.Generic;
using System.Windows.Input;
using Tizen.Xamarin.Forms.Extension;
+using TVMediaHub.Tizen.Controls;
using TVMediaHub.Tizen.DataModels;
using TVMediaHub.Tizen.Utils;
using TVMediaHub.Tizen.ViewModels;
private bool isNaviRunning = false;
NaviDirection naviDirection = default(NaviDirection);
+ private object focusedButton = null;
+
+ private static string ReturnKeyName = "Return";
+
private ImageViewerInfomation prevContent = null;
public static readonly BindableProperty SavedRotationCommandProperty = BindableProperty.Create("SavedRotationCommand", typeof(ICommand), typeof(ImageViewer), default(ICommand));
PropertyChanged += ImageViewerPropertyChanged;
}
+ private void grabReturnKey()
+ {
+ App.MainWindow.KeyGrab(ReturnKeyName, false);
+
+ App.MainWindow.KeyUp += ReturnKeyUpListener;
+ App.MainWindow.KeyDown += ReturnKeyDownListener;
+ }
+
+ private void ungrabReturnKey()
+ {
+ App.MainWindow.KeyUp -= ReturnKeyUpListener;
+ App.MainWindow.KeyDown -= ReturnKeyDownListener;
+
+ App.MainWindow.KeyUngrab(ReturnKeyName);
+ }
+
+ private void ReturnKeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ DbgPort.D("[ImageViwer] key up : " + e.KeyName);
+
+ if (!e.KeyName.Equals(ReturnKeyName))
+ {
+ return;
+ }
+
+ Image focusedBtnBG = null;
+ CustomImageButton focusedCustomImageBtn = null;
+
+ findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+ if (focusedBtnBG == null || focusedCustomImageBtn == null)
+ {
+ return;
+ }
+
+ focusedBtnBG.ScaleTo(3, 250);
+ focusedBtnBG.FadeTo(1, 250);
+
+ focusedCustomImageBtn.OnButtonReleased();
+ }
+
+ private void ReturnKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ DbgPort.D("[ImageViewer] key Down : " + e.KeyName);
+
+ if (!e.KeyName.Equals(ReturnKeyName))
+ {
+ return;
+ }
+
+ Image focusedBtnBG = null;
+ CustomImageButton focusedCustomImageBtn = null;
+
+ findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+ if (focusedBtnBG == null || focusedCustomImageBtn == null)
+ {
+ return;
+ }
+
+ focusedBtnBG.ScaleTo(1, 250);
+ focusedBtnBG.FadeTo(0, 250);
+
+ focusedCustomImageBtn.OnButtonPressed();
+ }
+
+ private void findFocusedItems(out Image focusedBtnBG, out CustomImageButton focusedCustomImageBtn)
+ {
+ List<Button> buttons = new List<Button> { RotateBtn, ZoomBtn, LeftNaviBtn, RightNaviBtn, SlideShowBtn, OptionBtn };
+ Image[] imageBGs = new Image[6] { RotateBg, ZoomBg, LeftNaviBg, RightNaviBg, SlideShowBg, OptionBG };
+ CustomImageButton[] customImageButtons = new CustomImageButton[6] { RotateImage, ZoomImage, LeftImage, RightImage, SlideShowImage, OptionImage };
+
+ int index = buttons.FindIndex(x => x.Equals(focusedButton));
+
+ focusedBtnBG = imageBGs[index];
+ focusedCustomImageBtn = customImageButtons[index];
+ }
+
private void InitializeCurrentImage()
{
Thumb1.Source = CurrentImage.FilePath;
{
RotateBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
RotateBg.ScaleTo(3, 250);
RotateBg.FadeTo(1, 250);
};
ZoomBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
ZoomBg.ScaleTo(3, 250);
ZoomBg.FadeTo(1, 250);
};
- LeftNativation.Focused += (s, e) =>
+ LeftNaviBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
LeftNaviBg.TranslationX = 7;
LeftNaviBg.ScaleTo(3, 250);
LeftNaviBg.FadeTo(1, 250);
};
- RightNativation.Focused += (s, e) =>
+ RightNaviBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
RightNaviBg.ScaleTo(3, 250);
RightNaviBg.FadeTo(1, 250);
};
SlideShowBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
SlideShowBg.ScaleTo(3, 250);
SlideShowBg.FadeTo(1, 250);
};
OptionBtn.Focused += (s, e) =>
{
+ focusedButton = s;
+
OptionBG.ScaleTo(3, 250);
OptionBG.FadeTo(1, 250);
};
ZoomBg.ScaleTo(1, 250);
ZoomBg.FadeTo(0, 250);
};
- LeftNativation.Unfocused += (s, e) =>
+ LeftNaviBtn.Unfocused += (s, e) =>
{
LeftNaviBg.ScaleTo(1, 250);
LeftNaviBg.FadeTo(0, 250);
};
- RightNativation.Unfocused += (s, e) =>
+ RightNaviBtn.Unfocused += (s, e) =>
{
RightNaviBg.ScaleTo(1, 250);
RightNaviBg.FadeTo(0, 250);
GradientDim.WidthRequest = width;
}
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+
+ grabReturnKey();
+ }
+
protected override void OnDisappearing()
{
base.OnDisappearing();
+ ungrabReturnKey();
+
SavedRotationCommand?.Execute(Convert.ToDouble(-1));
+
+ Image focusedBtnBG = null;
+ CustomImageButton focusedCustomImageBtn = null;
+
+ findFocusedItems(out focusedBtnBG, out focusedCustomImageBtn);
+
+ if (focusedBtnBG == null || focusedCustomImageBtn == null)
+ {
+ return;
+ }
+
+ focusedBtnBG.Scale = 1;
+ focusedBtnBG.Opacity = 0;
+ focusedCustomImageBtn.OnButtonReleased();
}
}
}