public IPropertyFilterInfo CreateFilterInfo(LogItemProperty prop, Action <LogItemProperty, Control> changedAction) { Control ctrl; if (prop == LogItemProperty.IsMarked) { CheckBox cb = new CheckBox(); cb.IsThreeState = true; cb.IsChecked = null; cb.Click += Cb_Click; ctrl = cb; } else { TextBox tb = new TextBox(); Style txtStyle = Application.Current.FindResource("RoundWatermarkTextBox") as Style; if (txtStyle != null) { tb.Style = txtStyle; } tb.KeyUp += Tb_KeyUp; ctrl = tb; } IPropertyFilter filter = CreateFilterProperty(prop, ctrl); ctrl.DataContext = new Holder(changedAction, prop, filter); return(new PropertyFilterInfo(ctrl, filter)); }
public bool Matches(LogItem item, LogItemProperty property) { if (!_expectation.HasValue) { return(true); } return(_expectation.Value.Equals(item.Get(property))); }
public void Add(LogItemProperty prop, IPropertyFilter filter) { if (filter == null) { _filters.Remove(prop); } else { _filters[prop] = filter; } }
public IPropertyFilter CreateFilterProperty(LogItemProperty prop, Control control) { IPropertyFilter result; if (prop == LogItemProperty.IsMarked) { result = new SimpleBoolPropertyFilter(); } else { result = new ContainsAllTokenStringPropertyFilter(true, true); } result.Update(control); return(result); }
public object Get(LogItemProperty prop) { switch (prop) { case LogItemProperty.IsMarked: return(IsMarked); case LogItemProperty.Id: return(Id); case LogItemProperty.Path: return(Path); case LogItemProperty.TimeStamp: return(TimeStamp.ToString(PluginManager.Instance.Context.DateTimeFormat)); case LogItemProperty.Logger: return(Logger); case LogItemProperty.Thread: return(Thread); case LogItemProperty.Message: return(Message); case LogItemProperty.MachineName: return(MachineName); case LogItemProperty.UserName: return(UserName); case LogItemProperty.HostName: return(HostName); case LogItemProperty.App: return(App); case LogItemProperty.Throwable: return(Throwable); case LogItemProperty.Class: return(Class); case LogItemProperty.Method: return(Method); case LogItemProperty.File: return(File); case LogItemProperty.Line: return(Line); case LogItemProperty.Uncategorized: return(Uncategorized); case LogItemProperty.Level: return(Level); case LogItemProperty.LevelIndex: return(LevelIndex); default: throw new NotImplementedException("Property " + prop); } }
public bool Matches(LogItem item, LogItemProperty property) { if (filterValue == null) { return(true); } object given = item.Get(property); if (given == null || given.Equals(string.Empty)) { return(true); } string g = given.ToString(); if (ignoreCase) { g = g.ToLowerInvariant(); } return(Test(g)); }
public void Remove(LogItemProperty prop) { _filters.Remove(prop); }
public Holder(Action <LogItemProperty, Control> changedAction, LogItemProperty property, IPropertyFilter filter) { _changedAction = changedAction; _property = property; _filter = filter; }
public void BuildDataGrid(IList <ColumnItem> columns) { if (_dg == null) { return; } if (columns != null) { foreach (ColumnItem item in columns) { DataGridColumn col; if (item.Field.Equals("IsMarked")) { DataGridCheckBoxColumn cbCol = new DataGridCheckBoxColumn(); cbCol.IsReadOnly = false; col = cbCol; cbCol.Header = item.Header; Binding bind = new Binding(item.Field) { Mode = BindingMode.TwoWay }; cbCol.Binding = bind; } else { DataGridTextColumn textCol = new DataGridTextColumn(); col = textCol; textCol.Header = item.Header; Binding bind = new Binding(item.Field) { Mode = BindingMode.OneWay }; bind.ConverterCulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Resources.CultureName); if (!String.IsNullOrWhiteSpace(item.StringFormat)) { bind.StringFormat = item.StringFormat; } textCol.Binding = bind; } if (item.Alignment == CellAlignment.CENTER && _centerCellStyle != null) { col.CellStyle = _centerCellStyle; } if (item.MinWidth != null) { col.MinWidth = item.MinWidth.Value; } if (item.Width != null) { col.Width = item.Width.Value; } col.Visibility = item.IsVisible ? Visibility.Visible : Visibility.Collapsed; //Add column to datagrid _dg.Columns.Add(col); Control filterControl = null; if (_txtSearchPanel != null) { Binding widthBind = new Binding() { Path = new PropertyPath("ActualWidth"), Source = col, Mode = BindingMode.OneWay, Converter = _adjConv, ConverterParameter = "-2" }; LogItemProperty prop = (LogItemProperty)Enum.Parse(typeof(LogItemProperty), item.Field); IPropertyFilterInfo info = FilterManager.CreateFilterInfo(prop, _filterChanged); info.Control.SetBinding(TextBox.WidthProperty, widthBind); info.Control.ToolTip = String.Format(Resources.FilteredGridManager_BuildDataGrid_FilterTextBox_Tooltip, item.Header); info.Control.Tag = info.Control.ToolTip.ToString().ToLower(); info.Control.Visibility = item.IsVisible ? Visibility.Visible : Visibility.Collapsed; info.Control.Name = getTextBoxName(item.Field); _txtSearchPanel.Children.Add(info.Control); filterControl = info.Control; Filter.Add(prop, info.Filter); } columnMap.Add(item.Header, new Tuple <DataGridColumn, Control, string>(col, filterControl, item.Field)); } } _dg.ColumnReordered += OnColumnReordered; }