コード例 #1
0
        /// <summary>
        /// Match View Column filter Value (if any) with item property value
        /// and determine if this item should be displayed or not
        /// </summary>
        /// <param name="col"></param>
        /// <param name="logitem"></param>
        /// <returns></returns>
        public static bool MatchTextFilterColumn(ColumnsViewModel col,
                                                 ILogEntry logitem)
        {
            if (col != null)
            {
                foreach (ColumnItemViewModel colItem in col.DataGridColumns)
                {
                    // Crashs on filtering LevelIndex field is fixed with the second condition of this if, but it´s not a clean fix...
                    if (string.IsNullOrEmpty(colItem.ColumnFilterValue) == false && !colItem.Field.Equals("LevelIndex"))
                    {
                        object val = GetItemValue(logitem, colItem.Header);

                        if (val != null)
                        {
                            string valToCompare;
                            if (val is DateTime)
                            {
                                valToCompare = ((DateTime)val).ToString(GlobalHelper.DisplayDateTimeFormat,
                                                                        CultureInfo.GetCultureInfo
                                                                            (Resources.CultureName));
                            }
                            else
                            {
                                valToCompare = val.ToString();
                            }

                            if (
                                valToCompare.IndexOf(colItem.ColumnFilterValue,
                                                     StringComparison.OrdinalIgnoreCase) < 0)
                            {
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public DisplayLogViewModel(IManageTextMarkersViewModel interfaceTextMarkerViewModel)
        {
            CommandClearFilters = new CommandRelay(CommandClearFiltersExecute, CommandClearFilterCanExecute);
            CommandResetFilter  = new CommandRelay(CommandResetFilterExecute, CommandResetFilterCanExecute);
            CommandApplyFilter  = new CommandRelay(CommandApplyFilterExecute, CommandApplyFilterCanExecute);
            FilterYalvView      = new CommandRelay(CommandFilterYalvView, CommandApplyFiltersCanExecute);

            SelectAll             = true;
            IsFiltered            = true;
            LogEntryRowViewModels = new ObservableCollection <LogEntryRowViewModel>();
            RebuildLogView(LogEntryRowViewModels);
            _filterViewModel = new FilterConverterViewModel(YalvRegistry.Instance.ActualWorkspace.CurrentAnalysis);
            _filterViewModel.PropertyChanged += (sender, args) => RefreshView();

            interfaceTextMarkerViewModel.MarkerDeleted +=
                (sender, args) => OnMarkerDeleteExecuted(sender, (TextMarkerEventArgs)args);
            interfaceTextMarkerViewModel.MarkerAdded += (sender, args) => RefreshView();

            // Default constructor contains column definitions
            // The callback is invocked when a column filter string item is changed
            // so we know that we should update the viewmodel filter
            mDataGridColumns = new ColumnsViewModel(ColumnsVmUpdateColumnFilter);
        }