Ejemplo n.º 1
0
        internal void SetPad(PropertyPad pad)
        {
            propertyPad = pad;

            if (propertyPad != null)
            {
                if (lastPadProvider != null)
                {
                    object[] provs = GetProvidersForObject(lastComponent, lastPadProvider.GetProvider());
                    if (provs.Length > 0)
                    {
                        propertyPad.PropertyGrid.SetCurrentObject(lastComponent, provs);
                    }
                    else
                    {
                        propertyPad.BlankPad();
                    }

                    var customizer = lastPadProvider as IPropertyPadCustomizer;
                    if (customizer != null)
                    {
                        customizer.Customize(pad.PadWindow, pad.PropertyGrid);
                    }
                    propertyPad.PropertyGrid.Changed += OnPropertyGridChanged;
                }
                else if (lastCustomProvider != null)
                {
                    try {
                        var currentCustomWidget = lastCustomProvider.GetCustomPropertyWidget();
                        if (currentCustomWidget != null)
                        {
                            propertyPad.UseCustomWidget(currentCustomWidget);
                            if (lastCustomProvider is IPropertyPadCustomizer customizer)
                            {
                                customizer.Customize(pad.PadWindow, null);
                            }
                        }
                    } catch (Exception ex) {
                        LoggingService.LogInternalError($"There was an error trying to GetCustomPropertyWidget from '{lastCustomProvider.GetType ()}' provider", ex);
                        ReSetPad();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void SetPadContent(ICustomPropertyPadProvider provider, Gtk.Widget commandRouteOrigin)
        {
            if (provider != null)
            {
                if (lastCustomProvider == provider)
                {
                    return;
                }

                // If there was a pad provider reset it now.
                DisposePropertyPadProvider();
                DisposeCustomPropertyPadProvider();

                lastCustomProvider = provider;

                if (propertyPad != null)
                {
                    try {
                        var customWidget = provider.GetCustomPropertyWidget();
                        if (customWidget != null)
                        {
                            propertyPad.UseCustomWidget(customWidget);
                            propertyPad.CommandRouteOrigin = commandRouteOrigin;

                            var customizer = provider as IPropertyPadCustomizer;
                            if (customizer != null)
                            {
                                customizer.Customize(propertyPad.PadWindow, null);
                            }
                        }
                        else
                        {
                            propertyPad?.BlankPad();
                            return;
                        }
                    } catch (Exception ex) {
                        LoggingService.LogInternalError($"There was an error trying to GetCustomPropertyWidget from '{lastCustomProvider.GetType ()}' provider", ex);
                        propertyPad?.BlankPad();
                        return;
                    }
                }
            }
            else
            {
                ReSetPad();
            }
        }