示例#1
0
        public ComponentType[] GetComponentTypes()
        {
            if (!disposed)
            {
                ArrayList types = new ArrayList();
                types.AddRange(project.GetComponentTypes());

                // Add actions from the local action groups

                WidgetComponent c = rootWidget as WidgetComponent;
                if (c != null)
                {
                    foreach (ActionGroupComponent grp in c.GetActionGroups())
                    {
                        foreach (ActionComponent ac in grp.GetActions())
                        {
                            types.Add(new ComponentType(app, ac));
                        }
                    }
                }
                return((ComponentType[])types.ToArray(typeof(ComponentType)));
            }
            else
            {
                return(new ComponentType[0]);
            }
        }
示例#2
0
        internal void NotifyWidgetNameChanged(object obj, string oldName, string newName, bool isRoot)
        {
            WidgetComponent c = obj != null ? (WidgetComponent)App.GetComponent(obj, null, null) : null;

            if (c != null)
            {
                c.UpdateName(newName);
            }

            if (isRoot)
            {
                WidgetInfo wi = GetWidget(oldName);
                if (wi != null)
                {
                    wi.NotifyNameChanged(newName);
                }
            }

            GuiDispatch.InvokeSync(
                delegate {
                if (c != null)
                {
                    if (ComponentNameChanged != null)
                    {
                        ComponentNameChanged(this, new ComponentNameEventArgs(this, c, oldName));
                    }
                }
            }
                );
        }
示例#3
0
        internal Component GetComponent(object cbackend, string name, string type)
        {
            try {
                lock (components) {
                    if (cbackend == null)
                    {
                        return(null);
                    }

                    Component c = (Component)components [cbackend];
                    if (c != null)
                    {
                        return(c);
                    }

                    // If the remote object is already disposed, don't try to create a
                    // local component.
                    if (cbackend is ObjectWrapper && ((ObjectWrapper)cbackend).IsDisposed)
                    {
                        return(null);
                    }

                    if (cbackend is Wrapper.Action)
                    {
                        c = new ActionComponent(this, cbackend, name);
                        ((ObjectWrapper)cbackend).Frontend = c;
                    }
                    else if (cbackend is Wrapper.ActionGroup)
                    {
                        c = new ActionGroupComponent(this, cbackend, name);
                        ((Wrapper.ActionGroup)cbackend).Frontend = c;
                    }
                    else if (cbackend is ObjectWrapper)
                    {
                        c = new WidgetComponent(this, cbackend, name, type != null ? GetComponentType(type) : null);
                        ((ObjectWrapper)cbackend).Frontend = c;
                    }
                    else if (cbackend == null)
                    {
                        throw new System.ArgumentNullException("cbackend");
                    }
                    else
                    {
                        throw new System.InvalidOperationException("Invalid component type: " + cbackend.GetType());
                    }

                    components [cbackend] = c;
                    return(c);
                }
            }
            catch (System.Runtime.Remoting.RemotingException)
            {
                // There may be a remoting exception if the remote wrapper
                // has already been disconnected when trying to create the
                // component frontend. This may happen since calls are
                // dispatched in the GUI thread, so they may be delayed.
                return(null);
            }
        }
示例#4
0
        public WidgetInfo AddNewComponent(XmlElement template)
        {
            object          ob = ProjectBackend.AddNewWidgetFromTemplate(template.OuterXml);
            WidgetComponent wc = (WidgetComponent)App.GetComponent(ob, null, null);
            WidgetInfo      wi = GetWidget(wc.Name);

            if (wi == null)
            {
                wi = new WidgetInfo(this, wc);
                widgets.Add(wi);
            }
            return(wi);
        }
示例#5
0
        public WidgetInfo AddNewComponent(ComponentType type, string name)
        {
            object          ob = ProjectBackend.AddNewWidget(type.Name, name);
            WidgetComponent wc = (WidgetComponent)App.GetComponent(ob, null, null);
            WidgetInfo      wi = GetWidget(wc.Name);

            if (wi == null)
            {
                wi = new WidgetInfo(this, wc);
                widgets.Add(wi);
            }
            return(wi);
        }
示例#6
0
		internal Component GetComponent (object cbackend, string name, string type)
		{
			try {
				lock (components) {
					Component c = (Component) components [cbackend];
					if (c != null)
						return c;

					// If the remote object is already disposed, don't try to create a
					// local component.
					if (cbackend is ObjectWrapper && ((ObjectWrapper)cbackend).IsDisposed)
						return null;
					
					if (cbackend is Wrapper.Action) {
						c = new ActionComponent (this, cbackend, name);
						((ObjectWrapper)cbackend).Frontend = c;
					} else if (cbackend is Wrapper.ActionGroup) {
						c = new ActionGroupComponent (this, cbackend, name);
						((Wrapper.ActionGroup)cbackend).Frontend = c;
					} else if (cbackend is ObjectWrapper) {
						c = new WidgetComponent (this, cbackend, name, type != null ? GetComponentType (type) : null);
						((ObjectWrapper)cbackend).Frontend = c;
					} else if (cbackend == null)
						throw new System.ArgumentNullException ("cbackend");
					else
						throw new System.InvalidOperationException ("Invalid component type: " + cbackend.GetType ());

					components [cbackend] = c;
					return c;
				}
			}
			catch (System.Runtime.Remoting.RemotingException)
			{
				// There may be a remoting exception if the remote wrapper
				// has already been disconnected when trying to create the
				// component frontend. This may happen since calls are
				// dispatched in the GUI thread, so they may be delayed.
				return null;
			}
		}