Ejemplo n.º 1
0
        void clientLogic_ClientLogicUI(object sender, ClientLogicUIEventArgs e)
        {
            if (this.Dispatcher.CheckAccess())
            {
                if (e.UIRequest == ClientLogicUIRequest.EventPackageRefreshComplete)
                {
                    listViewEvents.Items.Refresh();
                }
                else if (e.UIRequest == ClientLogicUIRequest.EventPackageListReady)
                {
                    UpdateState();

                    // if we just sorted then apply the relevant adorner
                    if ((_lastSortColumn != null) && (_nextSortAdorner != null))
                    {
                        AdornerLayer.GetAdornerLayer(_lastSortColumn).Add(_nextSortAdorner);
                        _lastSortAdorner = _nextSortAdorner;
                        _nextSortAdorner = null;
                    }
                }
            }
            else
            {
                this.Dispatcher.BeginInvoke(new Action <object, ClientLogicUIEventArgs>(clientLogic_ClientLogicUI), sender, e);
            }
        }
Ejemplo n.º 2
0
        private void SortColumnCore(GridViewColumnHeader header, ListSortDirection direction)
        {
            // get the binding path for the column associated with the clicked header
            string bindingPath;

            if (header.Column.DisplayMemberBinding == null)
            {
                // if DisplayMemberBinding is not set then the path should be the tag for the column
                bindingPath = header.Tag as string;
            }
            else
            {
                // id DisplayMemberBinding is set then get the binding path
                Binding columnBinding = header.Column.DisplayMemberBinding as Binding;
                Debug.Assert(columnBinding != null);
                bindingPath = columnBinding.Path.Path;
            }

            ICollectionView dataView = CollectionViewSource.GetDefaultView(_listView.ItemsSource);

            if (dataView != null)
            {
                using (dataView.DeferRefresh())
                {
                    dataView.SortDescriptions.Clear();
                    dataView.SortDescriptions.Add(new SortDescription(bindingPath, direction));
                    ApplyRemainingDefaults(ref dataView, bindingPath);
                }
            }

            if ((_lastHeaderClicked != null) && (_currentAdorner != null))
            {
                AdornerLayer.GetAdornerLayer(_lastHeaderClicked).Remove(_currentAdorner);
            }

            _currentAdorner = new SortDirectionAdorner(header, direction);
            AdornerLayer.GetAdornerLayer(header).Add(_currentAdorner);

            _lastHeaderClicked = header;
            _lastDirection     = direction;
        }
Ejemplo n.º 3
0
        private void listViewEventsHeader_Click(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader header = e.OriginalSource as GridViewColumnHeader;

            if (header != null)
            {
                // can only sort columns with an associated tag
                string tagName = header.Tag as string;
                if (!string.IsNullOrEmpty(tagName))
                {
                    // remove previous sort adorner
                    if ((_lastSortColumn != null) && (_lastSortAdorner != null))
                    {
                        AdornerLayer.GetAdornerLayer(_lastSortColumn).Remove(_lastSortAdorner);
                    }
                    _lastSortAdorner = null;

                    ListSortDirection direction = ListSortDirection.Descending;

                    if (header == _lastSortColumn)
                    {
                        if (_lastSortDirection == ListSortDirection.Ascending)
                        {
                            direction = ListSortDirection.Descending;
                        }
                        else
                        {
                            direction = ListSortDirection.Ascending;
                        }
                    }

                    // to be applied after the event packages are fetched
                    _nextSortAdorner = new SortDirectionAdorner(header, direction);

                    _lastSortDirection = direction;
                    _lastSortColumn    = header;

                    StackHashSortOrder sortOrder = new StackHashSortOrder();
                    sortOrder.Ascending = (direction == ListSortDirection.Ascending);
                    sortOrder.FieldName = tagName;

                    switch (tagName)
                    {
                    case "Id":
                    case "TotalHits":
                    case "CabCount":
                    case "BugId":
                    case "PlugInBugId":
                    case "EventTypeName":
                    case "DateCreatedLocal":
                    case "DateModifiedLocal":
                    case "WorkFlowStatusName":
                        // these fields are from the event
                        sortOrder.ObjectType = StackHashObjectType.Event;
                        break;

                    default:
                        // all other tags are from the event signature
                        sortOrder.ObjectType = StackHashObjectType.EventSignature;
                        break;
                    }

                    StackHashSortOrderCollection sort = new StackHashSortOrderCollection();
                    sort.Add(sortOrder);

                    ClientLogic clientLogic = this.DataContext as ClientLogic;
                    Debug.Assert(clientLogic != null);

                    // run the sort, returning to the first page
                    clientLogic.PopulateEventPackages(clientLogic.CurrentProduct,
                                                      clientLogic.LastEventsSearch,
                                                      sort,
                                                      1,
                                                      UserSettings.Settings.EventPageSize,
                                                      clientLogic.CurrentProduct == null ?
                                                      UserSettings.Settings.GetDisplayHitThreshold(UserSettings.InvalidContextId) :
                                                      UserSettings.Settings.GetDisplayHitThreshold(clientLogic.CurrentProduct.Id),
                                                      ClientLogicView.EventList,
                                                      PageIntention.First,
                                                      UserSettings.Settings.ShowEventsWithoutCabs);
                }
            }
        }