Ejemplo n.º 1
0
        private static void ProcessLayout(ConfigLayout layout, List <IPanelItemSpecs> specsList, StackPanel panel)
        {
            if (specsList == null)
            {
                return;
            }

            foreach (var specs in specsList)
            {
                var specsType = specs.GetType();
                var attr      = (AssociatedClassAttribute)specsType.GetCustomAttributes(typeof(AssociatedClassAttribute), true)[0];
                var itemType  = attr.Value;

                FrameworkElement item;

                // Refactored items
                if (itemType != typeof(StackPanel))
                {
                    // Compute specs
                    var computedSpecs = specs as IButtonSpecs;
                    var computedStyle = ApplyStyle(layout.DefaultButtonStyle, computedSpecs.Style);
                    computedStyle.Size  = computedSpecs.Size;
                    computedSpecs.Style = computedStyle;
                    item = (FrameworkElement)Activator.CreateInstance(itemType, computedSpecs);
                }
                else                     // Old items

                {
                    item = (FrameworkElement)Activator.CreateInstance(itemType, specs);

                    // Set size
                    if (panel.Orientation == Orientation.Vertical)
                    {
                        item.Height = specs.Size;
                    }
                    else
                    {
                        item.Width = specs.Size;
                    }
                }

                // Add to tree
                panel.Children.Add(item);

                // Special: Panel handling
                if (item is StackPanel childPanel)
                {
                    childPanel.Orientation = panel.Orientation == Orientation.Horizontal ?
                                             Orientation.Vertical :
                                             Orientation.Horizontal;

                    // Process Children
                    ProcessLayout(layout, ((PivotSpecs)specs).Items, childPanel);
                }
            }
        }
Ejemplo n.º 2
0
        public Config()
        {
            LoadLayoutErrors = new List <string>();
            Layout           = new ConfigLayout();
            State            = new ConfigState();

            LoadedImageStreams  = new List <MemoryStream>();
            LoadingImageStreams = new List <MemoryStream>();
            LoadedFonts         = new List <string>();
        }