Beispiel #1
0
        private dynamic GetLayout()
        {
            var     layoutProvider = PanelContainer as ILayoutProvider;
            dynamic layout         = new DynamicWrapper();

            if (layoutProvider != null)
            {
                dynamic layoutProviderLayout = layoutProvider.GetLayout();
                IEnumerable <dynamic> items  = layoutProviderLayout.Items;
                layout.LayoutPanel = new DynamicWrapper();
                if (items.Any())
                {
                    var firstItem = (layoutProviderLayout.Items.First() as IEnumerable).Cast <dynamic>().First();
                    ObjectHelper.SetProperty(layout.LayoutPanel, firstItem.Key, firstItem.Value);
                }

                ObjectHelper.SetProperty(layout, "Caption", layoutProviderLayout.Caption);
                ObjectHelper.SetProperty(layout, "Text", layoutProviderLayout.Text);
                ObjectHelper.SetProperty(layout, "DataSources", DataSourceSurface.GetLayout());
                ObjectHelper.SetProperty(layout, "Scripts", ScriptSurface.GetLayout());
                ObjectHelper.SetProperty(layout, "Parameters", ParametersSurface.GetLayout());
                ObjectHelper.SetProperty(layout, "ChildViews", ChildViewSurface.GetLayout());
                LayoutExtensions.RemoveEmptyEntries(layout);
            }
            return(layout);
        }
Beispiel #2
0
 private void ClearControls()
 {
     ObjectInspector.RemoveAllElements();
     ObjectInspector.FocusedPropertiesNode = ObjectInspector.PropertiesRootNode;
     DataSourceSurface.Clear();
     ScriptSurface.Clear();
     ParametersSurface.Clear();
     ChildViewSurface.Clear();
 }
Beispiel #3
0
        public void ProcessJson(dynamic instance)
        {
            ClearControls();

            var panel = new Panel();

            panel.Dock = DockStyle.Fill;
            ScrollableControl.Controls.Add(panel);
            panel.BringToFront();
            var watch = Stopwatch.StartNew();

            ObjectInspector.BeginUpdate();
            try
            {
                var layoutPanel = instance.LayoutPanel;
                if (layoutPanel != null)
                {
                    var layoutProvider     = PanelContainer as ILayoutProvider;
                    var propertiesProvider = PanelContainer as IPropertiesProvider;

                    propertiesProvider.LoadProperties(instance);

                    if (layoutProvider != null)
                    {
                        dynamic instanceLayout = new DynamicWrapper();
                        instanceLayout.Items = new List <dynamic>();
                        instanceLayout.Items.Add(layoutPanel);


                        layoutProvider.SetLayout(instanceLayout);
                        ((IAlignment)layoutProvider).AlignControls();
                    }
                }
                var dataSources = instance.DataSources;
                if (dataSources != null)
                {
                    DataSourceSurface.ProcessJson(dataSources);
                }
                var scripts = instance.Scripts;
                if (scripts != null)
                {
                    ScriptSurface.ProcessJson(scripts);
                }
                var parameters = instance.Parameters;
                if (parameters != null)
                {
                    ParametersSurface.ProcessJson(parameters);
                }
                var childViews = instance.ChildViews;
                if (childViews != null)
                {
                    ChildViewSurface.ProcessJson(childViews);
                }
            }
            finally
            {
                ObjectInspector.EndUpdate();
                ScrollableControl.Controls.Remove(panel);

                watch.Stop();
                LabelRendered.Text = string.Format("Rendered in {0}", watch.ElapsedMilliseconds);
            }
        }