Esempio n. 1
0
        public static PanelViewContainer Wrap(Widget widget)
        {
            var container = new PanelViewContainer();

            container.Widget = widget;
            return(container);
        }
Esempio n. 2
0
        protected void OnContainerUnpinned(object sender, EventArgs args)
        {
            PanelViewContainer container = sender as PanelViewContainer;

            if (this.currentInfoProvider != container.InfoProvider)
            {
                content.Remove(container);
            }

            if (container.IsOrphan())
            {
                container.Widget.Destroy();
                container.Dispose();
            }
            else
            {
                var maybePanelView = container.Widget as IPanelView;
                if (maybePanelView != null)
                {
                    maybePanelView.Refresh();
                    container.Visible = container.VisibleOnPanel;
                }
            }
            UpdatePanelVisibility();
        }
Esempio n. 3
0
        public void SetInfoProvider(IInfoProvider provider)
        {
            if (this.currentInfoProvider == provider)
            {
                return;
            }
            this.currentInfoProvider = provider;
            if (!providerToViewMap.ContainsKey(provider))
            {
                var views = PanelViewFactory.CreateAll(provider.InfoWidgets)
                            .Select(v => PanelViewContainer.Wrap(v))
                            .ToList();
                views.ForEach(v => v.Unpinned    += OnContainerUnpinned);
                views.ForEach(v => v.InfoProvider = provider);
                views.ForEach(v => (v.Widget as IPanelView)?.Refresh());
                providerToViewMap.Add(provider, views);
            }

            var childrenToRemove = content.Children.Where(v => !(v as PanelViewContainer).Pinned);

            foreach (var child in childrenToRemove)
            {
                content.Remove(child);
            }

            List <PanelViewContainer> newViews;

            if (!providerToViewMap.TryGetValue(provider, out newViews))
            {
                return;
            }
            foreach (var viewContainer in newViews)
            {
                bool alreadyOnPanel = viewContainer.Pinned;
                if (!alreadyOnPanel)
                {
                    content.Add(viewContainer);
                    content.SetChildPacking(viewContainer, false, false, 0, PackType.Start);
                    viewContainer.Visible = viewContainer.VisibleOnPanel;
                }
            }
            UpdatePanelVisibility();
        }