public void DeleteUXComponent(UXComponent component)
        {
            if (component != null)
            {
                foreach (PropertyInfo info in component.GetType().GetProperties())
                {
                    if (info.GetCustomAttributes(typeof(DomainReferenceAttribute), false).Count() > 0)
                    {
                        PropertyInfo idProperty = component.GetType().GetProperty(info.Name + "Id");

                        if (idProperty == null)
                        {
                            throw new Exception("Id property not found.");
                        }

                        Guid id = (Guid)idProperty.GetValue(component, null);

                        if (id != Guid.Empty)
                        {
                            if (info.PropertyType == typeof(PropertyMap))
                            {
                                PropertyMap map = PropertyMapDao.FindById(id);

                                if (map != null)
                                {
                                    PropertyMapDao.Delete(map);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        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);
                }
            }
        }
示例#3
0
        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);
                    }
                }
            }
        }
        private void PopulateComponentTypes()
        {
            componentCbx.Items.Clear();
            componentCbx.DisplayMember = "Name";

            Assembly assembly = Assembly.GetAssembly(typeof(VisualDesignerAttribute));

            VisualComponentItem selectedItem = null;

            foreach (Type t in assembly.GetTypes())
            {
                if (!OnlyBindables || (OnlyBindables && (t.GetInterface("IBindable") != null)))
                {
                    object[] attributes = t.GetCustomAttributes(typeof(VisualDesignerAttribute), false);

                    if (attributes.Count() > 0)
                    {
                        VisualComponentItem item = new VisualComponentItem();
                        item.Type = t;
                        item.Name = ((VisualDesignerAttribute)attributes[0]).ComponentName;

                        if ((UXComponent != null) && (UXComponent.GetType() == t))
                        {
                            item.Instance = UXComponent;
                            selectedItem  = item;
                        }

                        componentCbx.Items.Add(item);
                    }
                }
            }

            componentCbx.SelectedItem = selectedItem;
        }
示例#6
0
        public static IList <TType> GetAllComponents <TType>(UXComponent root)
            where TType : class
        {
            IList <TType> components = new List <TType>();

            GetAllComponents <TType>(components, root);

            return(components);
        }
示例#7
0
        private void ResolveDomainReferences(UXComponent component, Dictionary <Guid, IDomainObject> loadedObjects)
        {
            //New model
            foreach (PropertyInfo info in component.GetType().GetProperties())
            {
                if (info.GetCustomAttributes(typeof(DomainReferenceAttribute), true).Count() > 0)
                {
                    PropertyInfo idProperty = component.GetType().GetProperty(info.Name + "Id");

                    if (idProperty == null)
                    {
                        throw new Exception("Id property not found.");
                    }

                    Guid id = (Guid)idProperty.GetValue(component, null);

                    if (id != Guid.Empty)
                    {
                        IDomainObject refObj = null;
                        if (DataAccess.DomainXmlSerializationHelper.DontUseDBorSession)
                        {
                            if (DataAccess.DomainXmlSerializationHelper.DomainObjectLookUp.ContainsKey(info.PropertyType))
                            {
                                if (DataAccess.DomainXmlSerializationHelper.DomainObjectLookUp[info.PropertyType].ContainsKey(id))
                                {
                                    refObj = DataAccess.DomainXmlSerializationHelper.DomainObjectLookUp[info.PropertyType][id];
                                }
                            }
                        }
                        else
                        {
                            if (loadedObjects.ContainsKey(id))
                            {
                                refObj = loadedObjects[id];
                            }
                            else
                            {
                                refObj = ModelService.GetDomainObject(id, info.PropertyType);
                            }
                        }

                        if (refObj != null)
                        {
                            info.SetValue(component, refObj, null);
                        }
                        else
                        {
                            info.SetValue(component, null, null);
                            idProperty.SetValue(component, Guid.Empty, null);
                        }
                    }
                }
            }
        }
示例#8
0
 public static string GetHintResourceId(UXComponent component)
 {
     if (component.Hint != null)
     {
         return(string.Format("hint_{0}", component.Hint.Id.ToString().Replace('-', '_')));
     }
     else
     {
         return(null);
     }
 }
示例#9
0
        private bool ExistsInHintCollection(UXComponent comp)
        {
            HintCollection hintCollection = ModelService.GetDomainObject <HintCollection>(comp.Hint.HintCollection.Id);

            foreach (Hint hint in hintCollection.Hints)
            {
                if (hint.Id == comp.HintId)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#10
0
        private void SetHint(UXComponent component)
        {
            if (component is IBindable)
            {
                IBindable bindable     = component as IBindable;
                Hint      propertyHint = GetHintForMappedComponent(bindable);

                if (component.Hint != null && propertyHint != null)
                {
                    if ((propertyHint.Id == component.HintId) || (propertyHint.Id != component.HintId && !ExistsInHintCollection(component)))
                    {
                        component.Hint   = null;
                        component.HintId = Guid.Empty;
                    }
                }
            }
        }
示例#11
0
        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);
                    }
                }
            }
        }
        private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (propertyGrid.SelectedObject != null &&
                propertyGrid.SelectedObject is UXComponent)
            {
                UXComponent comp = propertyGrid.SelectedObject as UXComponent;

                if (e.ChangedItem.Label == "Name")
                {
                    if (!NamingGuidance.CheckNameNotInList(comp.Name, "Component Name", "Dialog Component Namelist", ComponentNames, false, true) ||
                        !NamingGuidance.CheckName(comp.Name, "Component Name", true))
                    {
                        comp.Name = (string)e.OldValue;
                    }
                }
            }
        }
示例#13
0
        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);
                    }
                }
            }
        }
示例#14
0
        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);
        }
示例#15
0
 public void InitializeUXComponent(UXComponent component)
 {
     InitializeUXComponent(component, new Dictionary <Guid, IDomainObject>());
 }
示例#16
0
        public Dialog CreateOrUpdateSearchPanelView(Dialog dialog)
        {
            dialog = this.GetDialogWithViewTree(dialog.Id);

            if (dialog != null)
            {
                View interfaceView = dialog.InterfaceView;

                View view = dialog.SearchPanelView;

                if (view != null)
                {
                    view = this.GetViewById(view.Id);
                    if (!view.IsLocked || view.LockedBy != Environment.UserName)
                    {
                        return(dialog);
                    }
                }
                else
                {
                    if (!dialog.IsLocked || dialog.LockedBy != Environment.UserName)
                    {
                        return(dialog);
                    }
                    view                = new Cdc.MetaManager.DataAccess.Domain.View();
                    view.Application    = interfaceView.Application;
                    view.BusinessEntity = interfaceView.BusinessEntity;
                    view.RequestMap     = interfaceView.RequestMap;
                    view.ResponseMap    = interfaceView.RequestMap;
                    view.Type           = ViewType.Standard;
                    view.Name           = string.Format("{0}SearchPanel", dialog.Name);
                    view.Title          = view.Name;

                    MetaManagerServices.GetModelService().SaveDomainObject(view);

                    MetaManagerServices.GetConfigurationManagementService().CheckOutDomainObject(view.Id, typeof(View));

                    dialog.SearchPanelView = view;

                    DialogDao.SaveOrUpdate(dialog);
                }

                if (view.VisualTree == null)
                {
                    view.VisualTree = new UXSearchPanel("SearchPanel");
                }

                view.Name  = string.Format("{0}SearchPanel", dialog.Name);
                view.Title = view.Name;

                ViewDao.SaveOrUpdate(view);

                foreach (MappedProperty property in interfaceView.RequestMap.MappedProperties)
                {
                    if ((property.IsSearchable) && (FindComponentInSearchPanel(view.VisualTree, property) == null))
                    {
                        UXSearchPanelItem item = new UXSearchPanelItem();

                        item.Caption = property.Name;

                        UXTextBox textBox = new UXTextBox(property.Name);
                        textBox.MappedProperty = property;
                        textBox.Width          = -1;
                        textBox.Height         = 21;

                        item.Children.Add(textBox);
                        item.IsDefaultVisible = true;

                        view.VisualTree.Children.Add(item);
                    }
                    else if (!property.IsSearchable)
                    {
                        UXComponent component = FindComponentInSearchPanel(view.VisualTree, property);

                        if (component != null)
                        {
                            Helpers.ViewHelper.ReplaceComponentInVisualTree(component.Parent, null);
                        }
                    }
                }

                SaveView(view);
            }

            return(dialog);
        }