Ejemplo n.º 1
0
        public void ConnectComponentValid(UIComponentBase component)
        {
            var type       = component.GetType();
            var attributes = default(IEnumerable <UIComponentDependencyAttribute>);

            if (type.HasCustomAttributes <UIComponentDependencyAttribute>(false, out attributes))
            {
                foreach (var attribute in attributes)
                {
                    var element = this.Configuration.GetElement <BooleanConfigurationElement>(
                        attribute.Section,
                        attribute.Element
                        );
                    if (element == null)
                    {
                        continue;
                    }
                    element.ConnectValue(value => component.IsComponentValid = this.IsComponentValid(type));
                }
            }
        }
Ejemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (this.ContentControl.Content is FrameworkElement element)
            {
                UIDisposer.Dispose(element);
            }
            var configuration = value as UIComponentConfiguration;

            if (configuration == null || string.IsNullOrEmpty(configuration.Component))
            {
                return(this.CreateSelector());
            }
            var component = default(UIComponentBase);
            var control   = Factory.CreateControl(configuration, out component);

            if (control == null)
            {
                //If a plugin was uninstalled the control will be null.
                return(this.CreateSelector());
            }
            this.Content = component;
            return(control);
        }
Ejemplo n.º 3
0
 public static void SetContent(UIComponentContainer source, UIComponentBase value)
 {
     source.SetValue(ContentProperty, value);
 }
Ejemplo n.º 4
0
 public static void SetIsComponentEnabled(UIComponentBase source, bool value)
 {
     source.SetValue(IsComponentEnabledProperty, value);
 }
Ejemplo n.º 5
0
 public static bool GetIsComponentEnabled(UIComponentBase source)
 {
     return((bool)source.GetValue(IsComponentEnabledProperty));
 }
Ejemplo n.º 6
0
        public FrameworkElement CreateControl(UIComponentConfiguration configuration, out UIComponentBase component)
        {
            var type = this.GetComponentType(configuration.Component);

            if (type == null || type == LayoutManager.PLACEHOLDER)
            {
                //A plugin was uninstalled.
                component = null;
                return(null);
            }
            component = ComponentActivator.Instance.Activate <UIComponentBase>(type);
            if (component is IUIComponentPanel panel)
            {
                panel.Component = configuration;
            }
            //Some components expect to be hosted in a Grid (Artwork..)
            //We might as well add a Rectangle to make the entire thing hit testable.
            var grid = new Grid();

            grid.Children.Add(new Rectangle()
            {
                Fill = Brushes.Transparent
            });
            grid.Children.Add(component);
            return(grid);
        }