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); } }
public ActionGroupComponent AddNewActionGroup(XmlElement template) { object ob = ProjectBackend.AddNewActionGroupFromTemplate(template.OuterXml); ActionGroupComponent ac = (ActionGroupComponent)App.GetComponent(ob, null, null); // Don't wait for the group added event to come to update the groups list since // it may be too late. ActionGroupInfo gi = GetActionGroup(ac.Name); if (gi == null) { gi = new ActionGroupInfo(this, ac.Name); groups.Add(gi); } return(ac); }
internal ActionGroupComponent[] GetActionGroups() { Wrapper.ActionGroup[] acs = ProjectBackend.GetActionGroups(); ArrayList comps = new ArrayList(acs.Length); for (int n = 0; n < acs.Length; n++) { ActionGroupComponent ag = (ActionGroupComponent)App.GetComponent(acs[n], null, null); if (ag != null) { comps.Add(ag); } } return((ActionGroupComponent[])comps.ToArray(typeof(ActionGroupComponent))); }
public ActionGroupComponent[] GetActionGroups() { if (app == null) { return(new ActionGroupComponent [0]); } ArrayList comps = new ArrayList(); Wrapper.ActionGroup[] groups = app.Backend.GetActionGroups((Wrapper.Widget)backend); for (int n = 0; n < groups.Length; n++) { ActionGroupComponent ag = (ActionGroupComponent)app.GetComponent(groups[n], null, null); if (ag != null) { comps.Add(ag); } } return((ActionGroupComponent[])comps.ToArray(typeof(ActionGroupComponent))); }
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; } }
public void RemoveActionGroup(ActionGroupInfo group) { ActionGroupComponent ac = (ActionGroupComponent)group.Component; ProjectBackend.RemoveActionGroup((Stetic.Wrapper.ActionGroup)ac.Backend); }