aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-25 14:13:28 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-25 14:13:28 +0300
commita7d1b350a7e6789942bd755f4a8dd48fb15a1a0a (patch)
tree1e0b202b176a05d0921c91e67a43221479525d6c /Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs
parent4571fffeccd4b037553fdeb0ddaff8005de67f23 (diff)
downloadTango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.tar.gz
Tango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.zip
Batch import/export jobs.
Diffstat (limited to 'Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs')
-rw-r--r--Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs90
1 files changed, 88 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs
index c1eba0b12..9561072d0 100644
--- a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs
+++ b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
@@ -14,12 +16,14 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Core.Commands;
+using Tango.Touch.Controls;
namespace Tango.Explorer
{
public class ExplorerControl : Control
{
private bool _changing_current_path;
+ private TouchListBox _listBox;
public String CurrentPath
{
@@ -45,6 +49,14 @@ namespace Tango.Explorer
public static readonly DependencyProperty SelectedItemProperty =
DependencyProperty.Register("SelectedItem", typeof(ExplorerItem), typeof(ExplorerControl), new PropertyMetadata(null, (d, e) => (d as ExplorerControl).OnSelectedItemChanged()));
+ public IEnumerable<ExplorerItem> SelectedItems
+ {
+ get { return (IEnumerable<ExplorerItem>)GetValue(SelectedItemsProperty); }
+ set { SetValue(SelectedItemsProperty, value); }
+ }
+ public static readonly DependencyProperty SelectedItemsProperty =
+ DependencyProperty.Register("SelectedItems", typeof(IEnumerable<ExplorerItem>), typeof(ExplorerControl), new PropertyMetadata(null, (d, e) => (d as ExplorerControl).OnSelectedItemsChanged()));
+
public RelayCommand BackCommand
{
get { return (RelayCommand)GetValue(BackCommandProperty); }
@@ -77,6 +89,21 @@ namespace Tango.Explorer
public static readonly DependencyProperty EnableFileSelectionProperty =
DependencyProperty.Register("EnableFileSelection", typeof(bool), typeof(ExplorerControl), new PropertyMetadata(true));
+ public bool EnableMultiSelect
+ {
+ get { return (bool)GetValue(EnableMultiSelectProperty); }
+ set { SetValue(EnableMultiSelectProperty, value); }
+ }
+ public static readonly DependencyProperty EnableMultiSelectProperty =
+ DependencyProperty.Register("EnableMultiSelect", typeof(bool), typeof(ExplorerControl), new PropertyMetadata(false));
+
+ public bool IsMultiSelecting
+ {
+ get { return (bool)GetValue(IsMultiSelectingProperty); }
+ set { SetValue(IsMultiSelectingProperty, value); }
+ }
+ public static readonly DependencyProperty IsMultiSelectingProperty =
+ DependencyProperty.Register("IsMultiSelecting", typeof(bool), typeof(ExplorerControl), new PropertyMetadata(false));
static ExplorerControl()
{
@@ -88,10 +115,22 @@ namespace Tango.Explorer
BackCommand = new RelayCommand(NavigateBack);
}
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _listBox = GetTemplateChild("PART_ListBox") as TouchListBox;
+ }
+
private void OnCurrentPathChanged()
{
if (_changing_current_path) return;
+ if (_listBox != null)
+ {
+ _listBox.IsMultiSelecting = false;
+ }
+
_changing_current_path = true;
if (CurrentPath == null)
@@ -119,7 +158,7 @@ namespace Tango.Explorer
private void OnSelectedItemChanged()
{
- if (SelectedItem != null)
+ if (SelectedItem != null && _listBox != null)
{
if (SelectedItem is ExplorerFolderItem)
{
@@ -128,13 +167,60 @@ namespace Tango.Explorer
CurrentFolder = folder;
SelectedItem = null;
}
- else if (SelectedItem is ExplorerFileItem && EnableFileSelection)
+ else if (SelectedItem is ExplorerFileItem && EnableFileSelection && !_listBox.IsMultiSelecting)
{
FileSelectedCommand?.Execute(SelectedItem);
}
}
}
+ private void OnSelectedItemsChanged()
+ {
+ if (SelectedItems != null)
+ {
+ if (SelectedItems is INotifyCollectionChanged)
+ {
+ (SelectedItems as INotifyCollectionChanged).CollectionChanged -= ExplorerControl_CollectionChanged;
+ (SelectedItems as INotifyCollectionChanged).CollectionChanged += ExplorerControl_CollectionChanged;
+ }
+
+ PreventMultiExtensionSelection();
+ }
+ }
+
+ private void ExplorerControl_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ PreventMultiExtensionSelection();
+ }
+
+ private void PreventMultiExtensionSelection()
+ {
+ if (_listBox != null && SelectedItems != null)
+ {
+ if (_listBox.IsMultiSelecting && _listBox.SelectedItems != null && _listBox.SelectedItems.Count > 1)
+ {
+ var firstItem = _listBox.SelectedItems.OfType<ExplorerFileItem>().FirstOrDefault();
+
+ if (firstItem != null)
+ {
+ foreach (var item in _listBox.SelectedItems.OfType<ExplorerFileItem>().ToList())
+ {
+ if (item.Extension.ToLower() != firstItem.Extension.ToLower())
+ {
+ var listBoxItem = _listBox.GetItems().FirstOrDefault(x => x.DataContext == item);
+
+ if (listBoxItem != null)
+ {
+ listBoxItem.IsSelected = false;
+ _listBox.SelectedItems.Remove(item);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
public void NavigateBack()
{
if (CurrentFolder != null)