}, "");
});
- DeleteContentCommand = new Command(() =>
+ DeleteContentCommand = new Command<MediaInformation>((SelectedItem) =>
{
+ if (!SelectedItem.Equals(""))
+ {
+ SelectedList.Clear();
+ SelectedList.Add(SelectedItem);
+ }
foreach (var info in SelectedList)
{
try
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Input;
+using Tizen.Content.MediaContent;
using TVMediaHub.Tizen.DataModels;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.Utils;
/// </summary>
private ICommand ItemClickCommand;
+ public delegate void ItemDeleteHandler(MediaInformation info);
+
+ public ItemDeleteHandler OnItemDeleteHandler;
+
/// <summary>
/// Gets or set ItemSource to display item
/// </summary>
public EventHandler<GroupItemFocusEventArgs> GroupItemFocused;
+ public ImageItem focusedItem;
+
/// <summary>
/// A constructor
/// </summary>
{
GroupItemFocused?.Invoke(view, new GroupItemFocusEventArgs(X + view.X));
GroupContentArea.RaiseChild(view);
+ focusedItem = view;
+ };
+ view.OnUnfocusedEventHandler += (se, ev) =>
+ {
+ if (focusedItem.Equals(view as ImageItem))
+ {
+ focusedItem = null;
+ }
};
view.OnItemClickedHandler += (info) =>
{
ItemClickCommand?.Execute(info);
};
+ view.DeleteItemHandler += (info) =>
+ {
+ OnItemDeleteHandler?.Invoke(info);
+ };
GroupContentArea.Children.Add(view, index / 3, index % 3);
index++;
}
{
ItemClickCommand = command;
}
+
+ /// <summary>
+ /// If there is focused image item, notify the menu key pressed event to focused video item for show context popup
+ /// </summary>
+ /// <returns>If group has a focused image item, true; otherwise, false</returns>
+ public bool NotifyMenuKeyPressedToFocusedItem()
+ {
+ if (focusedItem != null)
+ {
+ focusedItem.ShowContextPopup();
+ return true;
+ }
+ return false;
+ }
}
}
using System;
using System.ComponentModel;
using Tizen.Content.MediaContent;
+using Tizen.Xamarin.Forms.Extension;
using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
/// A delegate will be executed when the item is clicked
/// </summary>
/// <param name="info">A clicked item's MediaInformation</param>
- public delegate void ClickEventHandler(MediaInformation info);
+ public delegate void ItemEventHandler(MediaInformation info);
/// <summary>
/// A ClickEventHandler for click event of the item
/// </summary>
- public ClickEventHandler OnItemClickedHandler;
+ public ItemEventHandler OnItemClickedHandler;
+
+ public ItemEventHandler DeleteItemHandler;
/// <summary>
/// Identifies the IsDeleteMode bindable property
/// <param name="e">A Focus event's argument</param>
private void OnItemUnfocused(object sender, FocusEventArgs e)
{
+ OnUnfocusedEventHandler?.Invoke(sender, e);
Easing easing = new Easing(EasingFunction.EasyIn2);
this.AbortAnimation("FocusAnimation");
ImgFocused.Opacity = 0.0;
IsLoaded = true;
}
}
+ public void ShowContextPopup()
+ {
+ if (!FocusArea.IsFocused)
+ {
+ return;
+ }
+
+ ContextPopup popup = new ContextPopup();
+ popup.Items.Add(new ContextPopupItem("FILE INFO"));
+ popup.Items.Add(new ContextPopupItem("DELETE"));
+ popup.SelectedIndexChanged += selectedIndexChanged;
+ popup.Show(this, this.Width / 2, this.Height + SizeUtils.GetHeightSize(72));
+
+ }
+
+ private void selectedIndexChanged(object sender, EventArgs e)
+ {
+ var ctxPopup = sender as ContextPopup;
+ switch (ctxPopup.SelectedIndex)
+ {
+ case 0:
+ DbgPort.D("File info selected");
+ break;
+ case 1:
+ DeleteItemHandler?.Invoke(SelectedImage);
+ break;
+ }
+ ctxPopup.Dismiss();
+ }
}
}
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows.Input;
+using Tizen.Content.MediaContent;
using TVMediaHub.Tizen.Controls;
using TVMediaHub.Tizen.DataModels;
using TVMediaHub.Tizen.Models;
galleryGroup.BindingContext = group;
galleryGroup.SetClickCommand(OnClickCommand);
+ galleryGroup.OnItemDeleteHandler += (info) =>
+ {
+ ShowDeletePopup(info);
+ };
GalleryContentView.Children.Add(galleryGroup);
ImageGroupList.Add(galleryGroup);
GalleryContentView.TranslateTo(0, h0, 667);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
+
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+ // add Listener
+ App.MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, false);
+ App.MainWindow.KeyUp += MenuKeyListener;
+ }
+
+ protected override void OnDisappearing()
+ {
+ base.OnDisappearing();
+ // remove listener
+ App.MainWindow.KeyUp -= MenuKeyListener;
+ App.MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
+ }
+ private void MenuKeyListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ if (e.KeyName.Equals(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName))
+ {
+ NotifyMenuKeyPressed();
+ }
+ }
+
+ private void NotifyMenuKeyPressed()
+ {
+ if (GalleryContentView.Children.Count > 0)
+ {
+ foreach (ImageGroup group in GalleryContentView.Children)
+ {
+ if (group.NotifyMenuKeyPressedToFocusedItem())
+ {
+ break;
+ }
+ }
+
+ }
+ }
+
+ private async void ShowDeletePopup(MediaInformation item)
+ {
+ bool answer = await DisplayAlert("Delete", "Delete '" + item.Title + "'?", "Yes", "No");
+ if (answer)
+ {
+ DeleteContentCommand?.Execute(item);
+ }
+
+ }
}
}
}
ContextPopup popup = new ContextPopup();
- popup.Items.Add(new ContextPopupItem("FILE INFO"));
+ popup.Items.Add(new ContextPopupItem(" FILE INFO "));
popup.Items.Add(new ContextPopupItem("DELETE"));
popup.SelectedIndexChanged += selectedIndexChanged;
popup.Show(this, this.Width/2, this.Height + SizeUtils.GetHeightSize(72));