private void ViewModelOnCounterRemoved(CounterData counterData) { var graph = Chart.Graphs.FirstOrDefault(t => Equals(t.Tag, counterData.Key)); if (graph != null) { Chart.Graphs.Remove(graph); } }
private void ViewModelOnCounterAdded(CounterData counterData) { var graph = new LineGraph { Title = counterData.Name, Tag = counterData.Key, Brush = new SolidColorBrush(counterData.Color), ValueMemberPath = $"[{counterData.Id}]", StrokeThickness = 1, }; RenderOptions.SetEdgeMode(graph, EdgeMode.Aliased); Chart.Graphs.Add(graph); }
public void Remove(CounterData counterData) { _counters.Remove(counterData); var counterDatas = _categories[counterData.Category]; counterDatas.Remove(counterData); if (counterDatas.Count == 0) { _categories.Remove(counterData.Category); } OnCounterRemoved(counterData); if (_categories.Count == 0) { CurrentChartIndex = 0; for (var i = 0; i < _chartItems.Count; ++i) { _chartItems[i] = _emptyItem; } } }
protected virtual void OnCounterRemoved(CounterData counterData) { var handler = CounterRemoved; handler?.Invoke(counterData); }
public void Add(CounterKey key) { CounterData item; if (!_counters.TryGetItem(key, out item)) { if (++_lastColorIndex >= VividColors.All.Count) { _lastColorIndex = 0; } var counterData = new CounterData(key, VividColors.All[_lastColorIndex]); _counters.Add(counterData); List<CounterData> category; if (!_categories.TryGetValue(key.Category, out category)) { category = new List<CounterData>(); _categories.Add(key.Category, category); } category.Add(counterData); OnCounterAdded(counterData); } }