using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Threading;
+using TVMediaHub.Tizen.Utils;
+using System.IO;
+using System;
namespace TVMediaHub.Tizen.ViewModels
{
/// </summary>
public ICommand ChangeSortOptionCommand { get; set; }
+ /// <summary>
+ /// A command for deleting a image content
+ /// </summary>
+ public ICommand DeleteContentCommand { get; set; }
+
+ /// <summary>
+ /// A command for selecting all video contents
+ /// </summary>
+ public ICommand SelectAllContentCommand { get; set; }
+
private int SortBy;
/// <summary>
/// A flag that whether the content is delete mode or not
}
});
+ SelectAllContentCommand = new Command(() =>
+ {
+ foreach (var group in ImageList)
+ {
+ foreach (var info in group.Contents)
+ {
+ if (!SelectedList.Contains(info.Information))
+ {
+ SelectedList.Add(info.Information);
+ }
+ }
+ }
+
+ OnPropertyChanged("SelectedCount");
+ });
+
SavedRotationCommand = new Command<double>((rotation) =>
{
if (rotation == -1D)
ReadImageList(SortOption.Title);
}, "");
});
+
+ DeleteContentCommand = new Command(() =>
+ {
+ foreach (var info in SelectedList)
+ {
+ try
+ {
+ File.Delete(info.FilePath);
+ }
+ catch(Exception exception)
+ {
+ // TODO: Handling exceptions
+ DbgPort.E("Exception - " + exception.Message);
+ return;
+ }
+
+ MediaHubImpl.GetInstance.ImageProviderInstance.Delete(info);
+ }
+ });
+
+ OnPropertyChanged("DeleteModeChangeCommand");
+ OnPropertyChanged("ChangeSortOptionCommand");
}
private void GetImageData(int source, int sortby)
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.IO;
using System.Threading;
using System.Windows.Input;
using Tizen.Content.MediaContent;
public ICommand DeleteContentCommand { get; set; }
/// <summary>
+ /// A command for selecting all video contents
+ /// </summary>
+ public ICommand SelectAllContentCommand { get; set; }
+
+ /// <summary>
/// A command to set current video information
/// </summary>
public ICommand SetCurrentVideoInfo
});
DeleteContentCommand = new Command(() =>
{
- IsDeleteStatus = !IsDeleteStatus;
-
- foreach (var group in VideoList)
+ foreach (var info in SelectedList)
{
- foreach (var info in group.Contents)
+ try
{
- info.IsDeleteStatus = IsDeleteStatus;
- MediaHubImpl.GetInstance.VideoProviderInstance.Delete(info.Information);
+ File.Delete(info.FilePath);
}
+ catch(Exception exception)
+ {
+ // TODO: Handling exceptions
+ DbgPort.E("Exception - " + exception.Message);
+ return;
+ }
+
+ MediaHubImpl.GetInstance.VideoProviderInstance.Delete(info);
}
});
ChangeSortOptionCommand = new Command<string>((opt) =>
SetCurrentVideo(info);
}
});
+
+ SelectAllContentCommand = new Command(() =>
+ {
+ foreach (var group in VideoList)
+ {
+ foreach (var info in group.Contents)
+ {
+ if (!SelectedList.Contains(info.Information))
+ {
+ SelectedList.Add(info.Information);
+ }
+ }
+ }
+
+ OnPropertyChanged("SelectedCount");
+ });
OnPropertyChanged("ChangeTabStatusCommand");
OnPropertyChanged("ChangeSortOptionCommand");
}
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
DeleteModeChangeCommand="{Binding DeleteModeChangeCommand}"
OnClickCommand="{Binding SetCurrentImageInfo}"
+ DeleteContentCommand="{Binding DeleteContentCommand}"
+ SelectAllContentCommand="{Binding SelectAllContentCommand}"
+ SelectedCount="{Binding SelectedCount}"
Title="Gallery">
<RelativeLayout
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
/// <summary>
/// Identifies the OnClickCommand bindable property
/// </summary>
- public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(ImageItem), default(ICommand));
+ public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
/// <summary>
/// Gets or sets OnClickCommand
}
/// <summary>
+ /// Identifies the DeleteContentCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets DeleteContentCommand
+ /// </summary>
+ public ICommand DeleteContentCommand
+ {
+ get
+ {
+ return (ICommand)GetValue(DeleteContentCommandProperty);
+ }
+
+ set
+ {
+ SetValue(DeleteContentCommandProperty, value);
+ }
+ }
+
+ /// <summary>
+ /// Identifies the DeleteContentCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectAllContentCommandProperty = BindableProperty.Create("SelectAllContentCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SelectAllContent Command
+ /// </summary>
+ public ICommand SelectAllContentCommand
+ {
+ get { return (ICommand)GetValue(SelectAllContentCommandProperty); }
+ set { SetValue(SelectAllContentCommandProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the IsDeleteStatus bindable property
/// </summary>
- public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false);
+ public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(ImageTab), false);
/// <summary>
/// Gets or sets IsDeleteStatus
private List<KeyValuePair<double, Button>> BottomButtonList;
/// <summary>
+ /// Identifies the SelectedCount bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(ImageTab), 0);
+
+ /// <summary>
+ /// Gets or sets count of selected item
+ /// </summary>
+ public int SelectedCount
+ {
+ get { return (int)GetValue(SelectedCountProperty); }
+ set { SetValue(SelectedCountProperty, value); }
+ }
+
+ /// <summary>
/// A constructor
/// </summary>
public ImageTab()
/// <param name="e">An event's argument</param>
private void OnSelectAllClicked(object sender, EventArgs e)
{
-
+ SelectAllContentCommand?.Execute("");
}
/// <summary>
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">An event's argument</param>
- private void OnOKClicked(object sender, EventArgs e)
+ private async void OnOKClicked(object sender, EventArgs e)
{
- DeleteModeChangeCommand?.Execute("");
+ string title = "Delete";
+
+ if (SelectedCount < 1)
+ {
+ return;
+ }
+ else if (SelectedCount > 1)
+ {
+ title = "Delete Selected";
+ }
+
+ bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
+
+ if (answer)
+ {
+ DeleteContentCommand?.Execute("");
+ GetInformationsCommand?.Execute("");
+ }
+
FooterNormal.IsVisible = true;
FooterDelete.IsVisible = false;
SetFooterFocusChain(ImageTabScrollView.ScrollX);
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
GetInformationsCommand="{Binding GetInformationsCommand}"
OnClickCommand="{Binding SetCurrentVideoInfo}"
- DeleteContentCommand="{Binding DeleteContentCommand}">
+ DeleteContentCommand="{Binding DeleteContentCommand}"
+ SelectAllContentCommand="{Binding SelectAllContentCommand}"
+ SelectedCount="{Binding SelectedCount}">
<RelativeLayout
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
}
/// <summary>
+ /// Identifies the DeleteContentCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectAllContentCommandProperty = BindableProperty.Create("SelectAllContentCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SelectAllContent Command
+ /// </summary>
+ public ICommand SelectAllContentCommand
+ {
+ get { return (ICommand)GetValue(SelectAllContentCommandProperty); }
+ set { SetValue(SelectAllContentCommandProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the OnClickCommand bindable property
/// </summary>
- public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(VideoItem), default(ICommand));
+ public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
/// <summary>
/// Gets or sets OnClick Command
}
/// <summary>
+ /// Identifies the SelectedCount bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(VideoTab), 0);
+
+ /// <summary>
+ /// Gets or sets count of selected item
+ /// </summary>
+ public int SelectedCount
+ {
+ get { return (int)GetValue(SelectedCountProperty); }
+ set { SetValue(SelectedCountProperty, value); }
+ }
+
+ /// <summary>
/// A list of bottom buttons
/// </summary>
private List<KeyValuePair<double, Button>> BottomButtonList;
/// <param name="e">An event's argument</param>
private void OnSelectAllClicked(object sender, EventArgs e)
{
+ SelectAllContentCommand?.Execute("");
}
/// <summary>
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">An event's argument</param>
- private void OnOKClicked(object sender, EventArgs e)
+ private async void OnOKClicked(object sender, EventArgs e)
{
- // TODO : Change to delete Content command
- ChangeTabStatusCommand?.Execute("");
- DeleteContentCommand?.Execute("");
+ string title = "Delete";
+
+ if (SelectedCount < 1)
+ {
+ return;
+ }
+ else if (SelectedCount > 1)
+ {
+ title = "Delete Selected";
+ }
+
+ bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
+
+ if (answer)
+ {
+ DeleteContentCommand?.Execute("");
+ GetInformationsCommand?.Execute("");
+ }
+
FooterNormal.IsVisible = true;
FooterDelete.IsVisible = false;
SetFooterFocusChain(VideoTabScrollView.ScrollX);