private IDisposable DisplayUndoableImpl(IRenderable renderable, IModelDoc2 doc, int layer)
        {
            if (renderable == null)
            {
                throw new ArgumentNullException(nameof(renderable));
            }
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            GLDoubleBuffer.Update(b => b.SetItem(renderable, Tuple.Create(layer, renderable)));

            Redraw(doc);

            return(Disposable.Create(() =>
            {
                GLDoubleBuffer.Update(btr =>
                {
                    if (btr.ContainsKey(renderable))
                    {
                        return btr.Remove(renderable);
                    }
                    else
                    {
                        return btr;
                    }
                });
                Redraw(doc);
            }));
        }
Beispiel #2
0
        private IDisposable DisplayUndoableImpl(IRenderer renderer, IModelDoc2 doc, int layer)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            _GlDoubleBuffer.Update(b => b.SetItem(renderer, Tuple.Create(layer, renderer)));

            Redraw(doc);

            var s = renderer.NeedsRedraw.Subscribe(v => Redraw(doc));

            var d = Disposable.Create(() =>
            {
                s.Dispose();
                _GlDoubleBuffer.Update(btr =>
                {
                    if (btr.ContainsKey(renderer))
                    {
                        return(btr.Remove(renderer));
                    }
                    else
                    {
                        return(btr);
                    }
                });
                Redraw(doc);
            });
            var t = Thread.CurrentThread;

            return(Disposable.Create
                       (() =>
            {
                Debug.Assert(Thread.CurrentThread == t);
                d.Dispose();
            }));
        }