aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Explorer
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
parent4571fffeccd4b037553fdeb0ddaff8005de67f23 (diff)
downloadTango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.tar.gz
Tango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.zip
Batch import/export jobs.
Diffstat (limited to 'Software/Visual_Studio/Tango.Explorer')
-rw-r--r--Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs90
-rw-r--r--Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml50
2 files changed, 130 insertions, 10 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)
diff --git a/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml
index c920ce6bc..3ef77dea1 100644
--- a/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml
+++ b/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml
@@ -2,8 +2,17 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
xmlns:local="clr-namespace:Tango.Explorer">
+ <ResourceDictionary.MergedDictionaries>
+ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Colors.xaml"/>
+ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Fonts.xaml"/>
+ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/Shared.xaml"/>
+ </ResourceDictionary.MergedDictionaries>
+
+ <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+
<Style TargetType="{x:Type local:ExplorerControl}">
<Setter Property="Template">
<Setter.Value>
@@ -12,17 +21,42 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
- <touch:TouchListBox SelectionMode="None" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=CurrentFolder.Items}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=SelectedItem,Mode=TwoWay}">
+ <touch:TouchListBox x:Name="PART_ListBox"
+ IsMultiSelecting="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=IsMultiSelecting,Mode=OneWayToSource}"
+ ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=CurrentFolder.Items}"
+ SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=SelectedItem,Mode=TwoWay}"
+ SelectedItems="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=SelectedItems,Mode=TwoWay}">
+ <touch:TouchListBox.Style>
+ <Style TargetType="touch:TouchListBox" BasedOn="{StaticResource {x:Type touch:TouchListBox}}">
+ <Setter Property="SelectionMode" Value="None"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:ExplorerControl},Path=EnableMultiSelect}" Value="True">
+ <Setter Property="SelectionMode" Value="Multiple"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </touch:TouchListBox.Style>
<touch:TouchListBox.ItemTemplate>
<DataTemplate DataType="local:ExplorerItem">
<Border Padding="8" BorderBrush="#E9E9E9" BorderThickness="0 0 0 1">
- <DockPanel>
- <Image DockPanel.Dock="Left" Source="{Binding Icon}" Width="50" Height="50" />
- <StackPanel VerticalAlignment="Center" Margin="20 0 0 0">
- <TextBlock FontSize="16" Text="{Binding Name}"></TextBlock>
- <TextBlock Opacity="0.5" FontSize="12" Margin="0 5 0 0" Text="{Binding Description}"></TextBlock>
- </StackPanel>
- </DockPanel>
+ <Grid>
+ <DockPanel>
+ <Image DockPanel.Dock="Left" Source="{Binding Icon}" Width="50" Height="50" />
+ <StackPanel VerticalAlignment="Center" Margin="20 0 0 0">
+ <TextBlock FontSize="16" Text="{Binding Name}"></TextBlock>
+ <TextBlock Opacity="0.5" FontSize="12" Margin="0 5 0 0" Text="{Binding Description}"></TextBlock>
+ </StackPanel>
+ </DockPanel>
+
+ <Grid HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchListBox},Path=IsMultiSelecting,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <touch:TouchIcon
+ Icon="CheckCircleOutline"
+ Foreground="{StaticResource TangoPrimaryAccentBrush}"
+ Width="20"
+ Height="20"
+ Visibility="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchListBoxItem},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}"/>
+ </Grid>
+ </Grid>
</Border>
</DataTemplate>
</touch:TouchListBox.ItemTemplate>