public static void Draw(this Canvas canvas, DrawRecord record) { if (History == null) { History = new Dictionary <Canvas, Stack <int> >(); } Stack <int> history = null; if (History.ContainsKey(canvas)) { history = History[canvas]; } else { history = new Stack <int>(); History.Add(canvas, history); } var element = record.GetElement(); if (element == null) { return; } history.Push(canvas.Children.Add(element)); GC.Collect(); }
/// <summary> /// 绘制图形 /// </summary> /// <param name="record"></param> public void Draw(DrawRecord record) { var element = record.GetElement(); if (element == null) { return; } if (History.Any(item => item.Equals(element))) { return; } Children.Add(element); History.Push(element); GC.Collect(); }