private static void GetAllComponents <TType>(IList <TType> components, UXComponent component) where TType : class { if (component is TType) { components.Add(component as TType); } UXContainer container = null; if (component is UXGroupBox) { container = (component as UXGroupBox).Container; } else if (component is UXViewBox) { container = (component as UXViewBox).View.VisualTree; } else { container = component as UXContainer; } if (container != null) { foreach (UXComponent child in container.Children) { GetAllComponents(components, child); } } }
public static void ReplaceComponentInVisualTree(UXComponent oldComponent, UXComponent newComponent) { UXLayoutGrid grid = oldComponent.Parent as UXLayoutGrid; if (grid != null) { UXLayoutGridCell[] cells = grid.Cells; foreach (UXLayoutGridCell cell in cells) { if (cell.Component == oldComponent) { cell.Component = newComponent; } } grid.Cells = cells; } else { UXContainer container = oldComponent.Parent as UXContainer; if (newComponent == null) { container.Children.Remove(oldComponent); } else { int index = container.Children.IndexOf(oldComponent); container.Children[index] = newComponent; } } }
private void WalkViewComponentsAndUnmap(UXComponent component) { if (component != null) { if (component is IBindable) { IBindable bindable = component as IBindable; bindable.MappedProperty = null; } UXContainer container = null; if (component is UXGroupBox) { container = (component as UXGroupBox).Container; } else { container = component as UXContainer; } if (container != null) { foreach (UXComponent child in container.Children) { WalkViewComponentsAndUnmap(child); } } } }
public void FindComponentServiceReferences(UXComponent component, IDictionary <Guid, Service> references) { if (component != null) { foreach (PropertyInfo info in component.GetType().GetProperties()) { if (info.GetCustomAttributes(typeof(DomainReferenceAttribute), false).Count() > 0) { if (info.PropertyType == typeof(ServiceMethod)) { ServiceMethod method = info.GetValue(component, null) as ServiceMethod; if (method != null) { if (method.Service != null) { if (!references.ContainsKey(method.Service.Id)) { references.Add(method.Service.Id, method.Service); } } } } } } UXContainer container = null; if (component is UXGroupBox) { container = (component as UXGroupBox).Container; } else { container = component as UXContainer; } if (container != null) { foreach (UXComponent child in container.Children) { FindComponentServiceReferences(child, references); } } } }
public void InitializeUXComponent(UXComponent component, Dictionary <Guid, IDomainObject> loadedObjects) { if (component != null) { ResolveDomainReferences(component, loadedObjects); if ((component is IBindable) && (component.Hint == null)) { IBindable bindable = component as IBindable; component.Hint = GetHintForMappedComponent(bindable); if (component.Hint != null) { NHibernateUtil.Initialize(component.Hint.Text); } } UXContainer container = null; if (component is UXGroupBox) { container = (component as UXGroupBox).Container; } else { container = component as UXContainer; } if (container != null) { foreach (UXComponent child in container.Children) { InitializeUXComponent(child, loadedObjects); } } } }
private UXComponent FindComponentInSearchPanel(UXComponent component, MappedProperty property) { if (component is IBindable) { if ((component as IBindable).MappedProperty == property) { return(component); } } UXContainer container = null; if (component is UXGroupBox) { container = (component as UXGroupBox).Container; } else { container = component as UXContainer; } if (container != null) { foreach (UXComponent child in container.Children) { UXComponent result = FindComponentInSearchPanel(child, property); if (result != null) { return(result); } } } return(null); }