Example #1
0
        private static void OnGroupingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ArtPanelList artPanelList = (ArtPanelList)sender;

            artPanelList.Items.GroupDescriptions.Clear();

            switch ((Grouping)e.NewValue)
            {
            case Grouping.Local:
                //Group by whether the source is local or not
                artPanelList.Items.GroupDescriptions.Add(new LocalGroupDescription());
                break;

            case Grouping.Source:
                //Group by source name
                artPanelList.Items.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("SourceName"));
                break;

            case Grouping.SourceCategory:
                artPanelList.Items.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("SourceCategory"));
                break;

            case Grouping.Type:
                artPanelList.Items.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("CoverType"));
                break;

            case Grouping.Size:
                artPanelList.Items.GroupDescriptions.Add(new SizeGroupDescription());
                break;

            case Grouping.InfoUri:
                artPanelList.Items.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("InfoUri"));
                break;
            }
        }
Example #2
0
        private static object CoercePanelWidth(DependencyObject sender, object newValue)
        {
            if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift ||
                Keyboard.GetKeyStates(Key.Left) == KeyStates.Down ||
                Keyboard.GetKeyStates(Key.Up) == KeyStates.Down ||
                Keyboard.GetKeyStates(Key.Right) == KeyStates.Down ||
                Keyboard.GetKeyStates(Key.Down) == KeyStates.Down)
            {
                //Return the value unsnapped if Shift is held down (to mean unsnapped)
                //or if any of the direction keys are pressed (which means this is being
                //adjusted via the keyboard)
                return(newValue);
            }
            ArtPanelList artPanelList = (ArtPanelList)sender;

            if (artPanelList.PanelWidthSnapping > 0 && artPanelList.ItemsPresenter != null)
            {
                //Check if the panel width is close (within PanelWidthSnapping) to a neat arrangment
                double value = (double)newValue;
                double nearestArrangedPanelWidth = artPanelList.GetNearestArrangedPanelWidth(value);
                if (Math.Abs(nearestArrangedPanelWidth - value) <= artPanelList.PanelWidthSnapping)
                {
                    return(nearestArrangedPanelWidth);
                }
            }
            //Return the value un-coerced
            return(newValue);
        }
Example #3
0
 private static void OnNoAutoReSortChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     if (false.Equals(e.NewValue) && !false.Equals(e.OldValue))
     {
         // When turned off, perform a full re-sort and re-filter.
         ArtPanelList artPanelList = (ArtPanelList)sender;
         // HACK: Reapply filter to force refresh (as calling Refresh won't actually refresh if it doesn't think one is needed!)
         artPanelList.Items.Filter = artPanelList.Items.Filter;
     }
 }
Example #4
0
        private static void OnFilterPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ArtPanelList artPanelList = (ArtPanelList)sender;

            if (artPanelList.DisableFilters || (!artPanelList.UseMaximumImageSize && !artPanelList.UseMinimumImageSize && (artPanelList.AllowedCoverTypes == AllowedCoverType.Any)))
            {
                artPanelList.Items.Filter = null;                 //No filtering required
            }
            else
            {
                artPanelList.Items.Filter = new Predicate <object>(artPanelList.FilterPredicate);                //Apply the new filter
            }
        }
Example #5
0
        private static object CoerceThumbSize(DependencyObject sender, object value)
        {
            ArtPanelList artPanelList = (ArtPanelList)sender;

            if (artPanelList.ItemsPresenter == null)
            {
                return(value);
            }

            //Restrict to be no larger than the smallest dimension of the list control
            double maxSize = Math.Min(artPanelList.ItemsPresenter.ActualWidth, artPanelList.ActualHeight) - 10;

            return((double)value < maxSize ? value : maxSize);
        }
Example #6
0
        private static void OnSortDescriptionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ArtPanelList artPanelList = (ArtPanelList)sender;

            artPanelList.Items.SortDescriptions.Clear();

            SortDescription sortDescription = (SortDescription)e.NewValue;

            if (!String.IsNullOrEmpty(sortDescription.PropertyName))
            {
                artPanelList.Items.SortDescriptions.Add(sortDescription);
                //HACK: If sorting by ImageWidth, use ImageHeight as a secondary key.
                if (sortDescription.PropertyName == "ImageWidth")
                {
                    artPanelList.Items.SortDescriptions.Add(new SortDescription("ImageHeight", sortDescription.Direction));
                }
            }
        }