/// <summary> /// 设置样式,不存在添加,存在则用新样式替换旧样式 /// </summary> /// <param name="style">样式</param> public void SetStyle(LogShowStyle style) { lock (this._logLock) { var id = style.ID; if (this._styleDic.ContainsKey(id)) { this._styleDic[id] = style; } else { this._styleDic.Add(id, style); } } }
/// <summary> /// 移除样式 /// </summary> /// <param name="style">样式标识</param> public void RemoveStyle(LogShowStyle style) { if (style == null) { return; } lock (this._logLock) { var id = style.ID; if (this._styleDic.ContainsKey(id)) { this._styleDic.Remove(id); } } }
/// <summary> /// 构造函数 /// </summary> public LogControl() : base() { this.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; this.IsReadOnly = true; this.Background = Brushes.Black; this.BorderThickness = new Thickness(0d); this._paragraph = new Paragraph(); base.Document.Blocks.Clear(); base.Document.Blocks.Add(this._paragraph); this._primitiveShowLogDelegate = new Action <List <ShowLogItem> >(this.PrimitiveShowLog); this._priority = this.Priority; this._defaultStyle = new LogShowStyle(0, Colors.Gray) { Name = "默认样式" }; this.AddDefaultStyle(); this.StartRefreshLogThread(); }
/// <summary> /// 移除样式 /// </summary> /// <param name="style">样式标识</param> public void RemoveStyle(LogShowStyle style) { logControl.RemoveStyle(style); }
/// <summary> /// 设置样式,不存在添加,存在则用新样式替换旧样式 /// </summary> /// <param name="style">样式</param> public void SetStyle(LogShowStyle style) { logControl.SetStyle(style); }