Exemplo n.º 1
0
        public static void OnColumnsFilterChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ListViewEx lv = (ListViewEx)sender;

            if (lv.ColumnFilters != null)
            {
                ListViewColumnUtils.UpdateFilterPanel(lv, lv.Columns, lv.ColumnFilters);
            }
        }
Exemplo n.º 2
0
        public static void OnViewModeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ListViewEx fl = (ListViewEx)sender;

            if (args.NewValue == args.OldValue)
            {
                return;
            }
            //Debug.WriteLine(args.NewValue);
            ViewBase view = fl.View;

            if (args.Property.Equals(ViewModeProperty))
            {
                string viewMode = (string)args.NewValue;
                if (String.IsNullOrEmpty(viewMode))
                {
                    return;
                }
                string viewResourceName = viewMode + "View";
                view = (ViewBase)(fl.TryFindResource(viewResourceName));
                if (view != null)
                {
                    fl.View = view;
                }
                else
                {
                    Debug.WriteLine(String.Format("ListViewEx - {0} not found.", viewResourceName));
                }
            }

            if (fl.View != null)
            {
                //Only update columns if View is updated
                if (args.Property.Equals(ColumnsProperty) || args.Property.Equals(ViewModeProperty))
                {
                    ListViewColumnUtils.UpdateColumn(fl, fl.Columns);
                    fl.Dispatcher.Invoke(() =>
                    {
                        ListViewColumnUtils.UpdateFilterPanel(fl, fl.Columns, fl.ColumnFilters);
                    },
                                         System.Windows.Threading.DispatcherPriority.Input);
                }

                ////always update sort column
                ColumnInfo sortColumn = fl.Columns.Find(fl.SortBy);
                if (sortColumn != null)
                {
                    ListViewColumnUtils.UpdateSortSymbol(fl, sortColumn, fl.SortDirection);
                }
            }
            else
            {
                Debug.WriteLine(String.Format("ListViewEx - No view defined."));
            }
        }
Exemplo n.º 3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ProcessedItems = ((FileExplorer.WPF.UserControls.ListViewEx)(target));
                return;

            case 2:
                this.Sidebar = ((System.Windows.Controls.ContentControl)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemplo n.º 4
0
        public static void OnColumnsVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ListViewEx lv = (ListViewEx)sender;

            if (args.OldValue != args.NewValue)
            {
                if ((Visibility)args.NewValue == Visibility.Visible)
                {
                    lv.AddHandler(GridViewColumnHeader.ClickEvent, (RoutedEventHandler)lv.columnClickedHandler);
                }
                else
                {
                    lv.RemoveHandler(GridViewColumnHeader.ClickEvent, (RoutedEventHandler)lv.columnClickedHandler);
                }
            }
        }
Exemplo n.º 5
0
        public static void OnSelectionModeExChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ListViewEx      fl      = (ListViewEx)sender;
            SelectionModeEx selMode = (SelectionModeEx)args.NewValue;

            switch (selMode)
            {
            case SelectionModeEx.Single:
            case SelectionModeEx.Multiple:
            case SelectionModeEx.Extended:
                SelectionHelper.SetEnableSelection(fl, false);
                fl.SetValue(SelectionModeProperty, (SelectionMode)(int)selMode);
                break;

            case SelectionModeEx.SelectionHelper:
                SelectionHelper.SetEnableSelection(fl, true);
                break;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// If a filter is checked or unchecked, raise FilterChangedEvent.
        /// </summary>
        /// <param name="listView"></param>
        public static void RegisterFilterEvent(ListViewEx listView)
        {
            var p = UITools.FindVisualChild <GridViewHeaderRowPresenter>(listView);

            if (p != null)
            {
                var handler = (RoutedEventHandler)((o, e) =>
                {
                    ColumnFilter filter = (e.OriginalSource as MenuItem).DataContext as ColumnFilter;
                    if (filter != null)
                    {
                        ColumnInfo colInfo = ((VisualTreeHelper.GetParent(e.OriginalSource as DependencyObject))
                                              as StackPanel).DataContext as ColumnInfo;
                        listView.RaiseEvent(new FilterChangedEventArgs(e.Source)
                        {
                            ColumnInfo = colInfo, Filter = filter
                        });
                    }
                });
                p.AddHandler(MenuItem.CheckedEvent, handler);
                p.AddHandler(MenuItem.UncheckedEvent, handler);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Apply header template to GridViewColumns depending if it's selected and ascending.
        /// </summary>
        public static void UpdateSortSymbol(ListView listView, ColumnInfo sortCol,
                                            ListSortDirection sortDirection = ListSortDirection.Ascending)
        {
            GridViewColumnCollection columns = getColumnCols(listView);

            if (columns == null)
            {
                return;
            }

            GridViewHeaderRowPresenter presenter = UITools.FindVisualChild <GridViewHeaderRowPresenter>(listView);

            if (presenter != null)
            {
                GridViewColumnHeader foundHeader           = findColumnHeader(presenter, sortCol);
                IEnumerable <GridViewColumnHeader> headers = UITools.FindAllVisualChildren <GridViewColumnHeader>(presenter);

                foreach (var curHeader in headers)
                {
                    if (curHeader.Equals(foundHeader))
                    {
                        if (sortDirection == ListSortDirection.Ascending)
                        {
                            ListViewEx.SetColumnHeaderSortDirection(curHeader, -1);
                        }
                        else
                        {
                            ListViewEx.SetColumnHeaderSortDirection(curHeader, 1);
                        }
                    }
                    else
                    {
                        ListViewEx.SetColumnHeaderSortDirection(curHeader, 0);
                    }
                }
            }
        }