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/ExplorerControl.cs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs | 92 |
1 files changed, 3 insertions, 89 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) |
