diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.Explorer | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.Explorer')
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs | 92 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs | 16 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/Images/backup.png | bin | 3297 -> 0 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/Images/firmware.png | bin | 3956 -> 0 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj | 6 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml | 50 |
6 files changed, 12 insertions, 152 deletions
diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs index 9561072d0..77116e94c 100644 --- a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.IO; using System.Linq; using System.Text; @@ -16,14 +14,12 @@ 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 { @@ -49,14 +45,6 @@ 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); } @@ -79,7 +67,7 @@ namespace Tango.Explorer set { SetValue(FilterProperty, value); } } public static readonly DependencyProperty FilterProperty = - DependencyProperty.Register("Filter", typeof(String), typeof(ExplorerControl), new PropertyMetadata(null, (d, e) => (d as ExplorerControl).OnCurrentPathChanged())); + DependencyProperty.Register("Filter", typeof(String), typeof(ExplorerControl), new PropertyMetadata(null)); public bool EnableFileSelection { @@ -89,21 +77,6 @@ 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() { @@ -115,22 +88,10 @@ 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) @@ -158,7 +119,7 @@ namespace Tango.Explorer private void OnSelectedItemChanged() { - if (SelectedItem != null && _listBox != null) + if (SelectedItem != null) { if (SelectedItem is ExplorerFolderItem) { @@ -167,60 +128,13 @@ namespace Tango.Explorer CurrentFolder = folder; SelectedItem = null; } - else if (SelectedItem is ExplorerFileItem && EnableFileSelection && !_listBox.IsMultiSelecting) + else if (SelectedItem is ExplorerFileItem && EnableFileSelection) { 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/ExplorerFileDefinition.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs index d9c5d61e7..5df1900a4 100644 --- a/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs @@ -56,23 +56,9 @@ namespace Tango.Explorer Extension = ".tcc", }; - public static ExplorerFileDefinition Backup => new ExplorerFileDefinition() - { - Icon = ResourceHelper.GetImageFromResources("/Images/backup.png"), - Description = "Tango Backup", - Extension = ".tb", - }; - - public static ExplorerFileDefinition Firmware => new ExplorerFileDefinition() - { - Icon = ResourceHelper.GetImageFromResources("/Images/firmware.png"), - Description = "Tango Firmware Upgrade", - Extension = ".tfp", - }; - static ExplorerFileDefinition() { - _definitions = typeof(ExplorerFileDefinition).GetProperties(BindingFlags.Public | BindingFlags.Static).Where(x => x.PropertyType == typeof(ExplorerFileDefinition)).ToList().Select(x => x.GetValue(null, null) as ExplorerFileDefinition).ToList(); + _definitions = typeof(ExplorerFileDefinition).GetProperties(BindingFlags.Public | BindingFlags.Static).Where(x => x.PropertyType == typeof(ExplorerFileDefinition)).ToList().Select(x => x.GetValue(null,null) as ExplorerFileDefinition).ToList(); } public static ExplorerFileDefinition GetByExtension(String ext) diff --git a/Software/Visual_Studio/Tango.Explorer/Images/backup.png b/Software/Visual_Studio/Tango.Explorer/Images/backup.png Binary files differdeleted file mode 100644 index fab1fdb6d..000000000 --- a/Software/Visual_Studio/Tango.Explorer/Images/backup.png +++ /dev/null diff --git a/Software/Visual_Studio/Tango.Explorer/Images/firmware.png b/Software/Visual_Studio/Tango.Explorer/Images/firmware.png Binary files differdeleted file mode 100644 index af3ea4850..000000000 --- a/Software/Visual_Studio/Tango.Explorer/Images/firmware.png +++ /dev/null diff --git a/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj b/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj index 5412405ef..10f3b929e 100644 --- a/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj +++ b/Software/Visual_Studio/Tango.Explorer/Tango.Explorer.csproj @@ -111,11 +111,5 @@ <Resource Include="Images\pulse.png" /> <Resource Include="Images\update.png" /> </ItemGroup> - <ItemGroup> - <Resource Include="Images\backup.png" /> - </ItemGroup> - <ItemGroup> - <Resource Include="Images\firmware.png" /> - </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml index 3ef77dea1..c920ce6bc 100644 --- a/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Explorer/Themes/Generic.xaml @@ -2,17 +2,8 @@ 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> @@ -21,42 +12,17 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> - <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 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.ItemTemplate> <DataTemplate DataType="local:ExplorerItem"> <Border Padding="8" BorderBrush="#E9E9E9" BorderThickness="0 0 0 1"> - <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> + <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> </Border> </DataTemplate> </touch:TouchListBox.ItemTemplate> |
