Пример #1
0
        public bool FilterProperties(System.ComponentModel.IComponent component, System.Collections.IDictionary properties)
        {
            if (OldService != null)
            {
                OldService.FilterProperties(component, properties);
            }

            string[] PropertyNames = new string[properties.Keys.Count];
            properties.Keys.CopyTo(PropertyNames, 0);
            string        PN = string.Join(",", PropertyNames);
            List <string> AllowedPropertyNames = new List <string>(AllowedProperties["All"]);
            string        ComponentType        = component.GetType().Name;
            string        FullComponentType    = component.GetType().FullName;

            if (FullComponentType.Equals("System.Windows.Forms.Form"))
            {
                AllowedPropertyNames.Remove("Name");
            }
            if (AllowedProperties.ContainsKey(FullComponentType))
            {
                AllowedPropertyNames.AddRange(AllowedProperties[FullComponentType]);
            }
            foreach (string PropertyName in PropertyNames)
            {
                if (PropertyName.StartsWith("Name_") && !FullComponentType.Equals("System.Windows.Forms.Form"))
                {
                    continue;
                }
                if (!AllowedPropertyNames.Contains(PropertyName))
                {
                    properties.Remove(PropertyName);
                }
            }
            return(true);
        }
Пример #2
0
 // This method provides an opportunity to perform processing when a designer is initialized.
 // The component parameter is the component that the designer is associated with.
 public override void Initialize(System.ComponentModel.IComponent component)
 {
     // Always call the base Initialize method in an override of this method.
     base.Initialize(component);
     System.Reflection.Assembly a = component.GetType().Assembly;
     System.Reflection.Assembly b = typeof(VirtuosoDataAdapter).Assembly;
     _adapter = (VirtuosoDataAdapter)component;
 }
Пример #3
0
 public override void Initialize(System.ComponentModel.IComponent component)
 {
     base.Initialize(component);
     if (component.GetType() != typeof(DesignerMonitor))
     {
         throw new Exception("This designer requires a DesignerMonitor control.");
     }
     dm = (DesignerMonitor)component;
 }
Пример #4
0
 // Displays a list of components in the current design
 // document when the default action of the designer is invoked.
 private void ListComponents()
 {
     using (DesignerHostListForm listform = new DesignerHostListForm())
     {
         // Obtain an IDesignerHost service from the design environment.
         IDesignerHost host = (IDesignerHost)this.component.Site.GetService(typeof(IDesignerHost));
         // Get the project components container (control containment depends on Controls collections)
         IContainer container = host.Container;
         // Add each component's type name and name to the list box.
         foreach (IComponent component in container.Components)
         {
             listform.listBox1.Items.Add(component.GetType().Name + " : " + component.Site.Name);
         }
         // Display the form.
         listform.ShowDialog();
     }
 }
Пример #5
0
        public void Add(System.ComponentModel.IComponent component, string name)
        {
            IDesigner  designer = null;
            DesignSite site     = null;

            // Check we're not trying to add a null component
            if (component == null)
            {
                throw new ArgumentNullException("Cannot add a null component to the container.");
            }

            // Remove this component from its existing container, if applicable
            if (component.Site != null && component.Site.Container != this)
            {
                component.Site.Container.Remove(component);
            }

            // Make sure we have a name for the component
            if (name == null)
            {
                INameCreationService nameService = (INameCreationService)GetService(typeof(INameCreationService));
                name = nameService.CreateName(this, component.GetType());
            }

            // Make sure there isn't already a component with this name in the container
            if (ContainsName(name))
            {
                throw new ArgumentException("A component with this name already exists in the container.");
            }

            // Give the new component a site
            site = new DesignSite(this, name);
            site.SetComponent(component);
            component.Site = site;

            // Let everyone know there's a component being added
            if (ComponentAdding != null)
            {
                ComponentAdding(this, new ComponentEventArgs(component));
            }

            // Get the designer for this component
            if (components.Count == 0)
            {
                // This is the first component being added and therefore must offer a root designer
                designer      = TypeDescriptor.CreateDesigner(component, typeof(IRootDesigner));
                rootComponent = component;
            }
            else
            {
                designer = TypeDescriptor.CreateDesigner(component, typeof(IDesigner));
            }

            // If we got a designer, initialize it
            if (designer != null)
            {
                designer.Initialize(component);
                designers[component] = designer;
            }
            else
            {
                // This should never happen
                component.Site = null;
                throw new InvalidOperationException("Failed to get designer for this component.");
            }

            // Add to our list of extenderproviders if necessary
            if (component is IExtenderProvider)
            {
                IExtenderProviderService e = (IExtenderProviderService)GetService(typeof(IExtenderProviderService));
                e.AddExtenderProvider((IExtenderProvider)component);
            }

            // Finally we're able to add the component
            components.Add(component.Site.Name, component);
            if (ComponentAdded != null)
            {
                ComponentAdded(this, new ComponentEventArgs(component));
            }
        }