From 4a7771d292f931a45d4a816f9f819655f0f03d38 Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Tue, 10 Aug 2021 21:53:01 +0530 Subject: [PATCH] removed unnessary file and code from SearchResult window --- .../Modules/ListViewGridSortableBehavior.cs | 131 ------------------ FoliCon/Views/SearchResult.xaml | 13 -- 2 files changed, 144 deletions(-) delete mode 100644 FoliCon/Modules/ListViewGridSortableBehavior.cs diff --git a/FoliCon/Modules/ListViewGridSortableBehavior.cs b/FoliCon/Modules/ListViewGridSortableBehavior.cs deleted file mode 100644 index a2245915..00000000 --- a/FoliCon/Modules/ListViewGridSortableBehavior.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Data; -using Microsoft.Xaml.Behaviors; - -//https://www.codewrecks.com/post/old/2014/04/sorting-a-wpf-listview-in-grid-mode/ -//Usage: -// -// -// -// -// -// -// -// -// -// - -namespace FoliCon.Modules -{ - public class ListViewGridSortableBehavior : Behavior - { - public static readonly DependencyProperty HeaderStringProperty = - DependencyProperty.Register(nameof(HeaderString), typeof(object), typeof(GridViewColumnHeader)); - public object HeaderString - { - get => GetValue(HeaderStringProperty); - set => SetValue(HeaderStringProperty, value); - } - protected override void OnAttached() - { - AssociatedObject?.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridHeaderClickEventHandler)); - base.OnAttached(); - } - - private GridViewColumnHeader _lastHeaderClicked; - private ListSortDirection _lastDirection = ListSortDirection.Ascending; - void GridHeaderClickEventHandler(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is not GridViewColumnHeader headerClicked) return; - if (headerClicked.Role == GridViewColumnHeaderRole.Padding) return; - var direction = headerClicked != _lastHeaderClicked - ? ListSortDirection.Ascending - : _lastDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; - if (_lastHeaderClicked != null) - { - SetSortDownVisibility(_lastHeaderClicked, Visibility.Collapsed); - SetSortUpVisibility(_lastHeaderClicked, Visibility.Collapsed); - } - //string header = headerClicked.Column.Header as string; - var sortString = GetSortHeaderString(headerClicked); - if (string.IsNullOrEmpty(sortString)) return; - Sort(sortString, direction); - if (direction == ListSortDirection.Ascending) - { - SetSortDownVisibility(headerClicked, Visibility.Collapsed); - SetSortUpVisibility(headerClicked, Visibility.Visible); - } - else - { - SetSortDownVisibility(headerClicked, Visibility.Visible); - SetSortUpVisibility(headerClicked, Visibility.Collapsed); - } - // Remove arrow from previously sorted header - if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked) - { - _lastHeaderClicked.Column.HeaderTemplate = null; - } - _lastHeaderClicked = headerClicked; - _lastDirection = direction; - } - private void Sort(string sortBy, ListSortDirection direction) - { - var dataView = - CollectionViewSource.GetDefaultView(AssociatedObject.ItemsSource); - dataView.SortDescriptions.Clear(); - var sd = new SortDescription(sortBy, direction); - dataView.SortDescriptions.Add(sd); - dataView.Refresh(); - } - public static readonly DependencyProperty SortHeaderStringProperty = - DependencyProperty.RegisterAttached - ( - "SortHeaderString", - typeof(string), - typeof(GridViewColumnHeader) - ); - public static string GetSortHeaderString(DependencyObject obj) - { - return (string)obj.GetValue(SortHeaderStringProperty); - } - public static void SetSortHeaderString(DependencyObject obj, string value) - { - obj.SetValue(SortHeaderStringProperty, value); - } - public static readonly DependencyProperty SortDownVisibilityProperty = - DependencyProperty.RegisterAttached - ( - "SortDownVisibility", - typeof(Visibility), - typeof(GridViewColumnHeader), - new UIPropertyMetadata(Visibility.Collapsed) - ); - public static Visibility GetSortDownVisibility(DependencyObject obj) - { - return (Visibility)obj.GetValue(SortDownVisibilityProperty); - } - public static void SetSortDownVisibility(DependencyObject obj, Visibility value) - { - obj.SetValue(SortDownVisibilityProperty, value); - } - public static readonly DependencyProperty SortUpVisibilityProperty = - DependencyProperty.RegisterAttached - ( - "SortUpVisibility", - typeof(Visibility), - typeof(GridViewColumnHeader), - new UIPropertyMetadata(Visibility.Collapsed) - ); - public static Visibility GetSortUpVisibility(DependencyObject obj) - { - return (Visibility)obj.GetValue(SortUpVisibilityProperty); - } - public static void SetSortUpVisibility(DependencyObject obj, Visibility value) - { - obj.SetValue(SortUpVisibilityProperty, value); - } - } -} diff --git a/FoliCon/Views/SearchResult.xaml b/FoliCon/Views/SearchResult.xaml index 3f54b9a0..76bf8481 100644 --- a/FoliCon/Views/SearchResult.xaml +++ b/FoliCon/Views/SearchResult.xaml @@ -52,13 +52,7 @@ Command="{Binding SkipCommand}" IsCancel="True" ToolTip="{ex:Lang Key={x:Static langs:LangKeys.SkipThisTitle}}" /> - - - - @@ -66,13 +60,6 @@ - - -