Esempio n. 1
0
        private void UpdateViewInternal()
        {
            if (HeadlessMode)
            {
                SpaceTime.ClearChanges();
                return;
            }

            if (SpaceTime.AddedElements.Count == 0 && SpaceTime.ChangedElements.Count == 0 && SpaceTime.RemovedElements.Count == 0)
            {
                return;
            }
            resetHandle.Reset();
            Application.InvokeNextCycle(() =>
            {
                foreach (var e in SpaceTime.AddedElements)
                {
                    var renderer = thingBinder.Bind(e, SpaceTime);
                    renderers.Add(e, renderer);
                    this.Controls.Add(renderer);
                    SizeAndLocate(renderer);
                    OnBind.Fire(e);
                    renderer.OnRender();
                }

                foreach (var e in SpaceTime.ChangedElements)
                {
                    SizeAndLocate(renderers[e]);
                    renderers[e].OnRender();
                }

                foreach (var e in SpaceTime.RemovedElements)
                {
                    var renderer = renderers[e];
                    renderers.Remove(e);
                    Controls.Remove(renderer);
                }

                if (resizedSinceLastRender)
                {
                    foreach (var r in renderers.Values)
                    {
                        SizeAndLocate(r);
                    }
                }
                Application.Paint();
                resetHandle.Set();
            });

            resetHandle.WaitOne();
            resizedSinceLastRender = false;
            SpaceTime.ClearChanges();
            AfterUpdate.Fire();
        }
Esempio n. 2
0
        private void UpdateViewInternal(bool force)
        {
            foreach (var element in SpaceTime.AddedElements)
            {
                Application.QueueAction(() =>
                {
                    var renderer = thingBinder.Bind(element, SpaceTime);
                    renderers.Add(element, renderer);
                    this.Controls.Add(renderer);
                    SizeAndLocate(renderer);
                    renderer.OnRender();
                });
            }

            foreach (var t in SpaceTime.ChangedElements)
            {
                Application.QueueAction(() =>
                {
                    var renderer = renderers[t];
                    SizeAndLocate(renderer);
                    renderer.OnRender();
                });
            }

            foreach (var t in SpaceTime.RemovedElements)
            {
                Application.QueueAction(() =>
                {
                    var renderer = renderers[t];
                    renderers.Remove(t);
                    Controls.Remove(renderer);
                });
            }

            if (force || resizedSinceLastRender)
            {
                foreach (var renderer in renderers.Values)
                {
                    Application.QueueAction(() =>
                    {
                        SizeAndLocate(renderer);
                    });
                }
            }

            resizedSinceLastRender = false;
            SpaceTime.ClearChanges();
            Application.Paint();
        }