예제 #1
0
        private List <WidgetViewModBase> CreateVMObjects(IObjectContainer container)
        {
            List <WidgetViewModBase> all = new List <WidgetViewModBase>();

            //common widget
            foreach (IWidget newItem in container.WidgetList)
            {
                if (newItem != null && newItem.ParentGroup == null)
                {
                    WidgetViewModBase vmItem = WidgetFactory.CreateWidget(newItem);
                    vmItem.ParentPageVM = this;
                    all.Add(vmItem);
                }
            }

            //common master
            foreach (IMaster newItem in container.MasterList)
            {
                if (newItem != null && newItem.ParentGroup == null)
                {
                    WidgetViewModBase vmItem = WidgetFactory.CreateWidget(newItem);
                    vmItem.ParentPageVM = this;
                    all.Add(vmItem);
                }
            }

            //master and it's all children
            foreach (IGroup newGroup in container.GroupList)
            {
                GroupViewModel vmGroup = null;
                if (newGroup != null && newGroup.ParentGroup == null)
                {
                    vmGroup         = WidgetFactory.CreateGroup(newGroup) as GroupViewModel;
                    vmGroup.IsGroup = true;
                    vmGroup.Status  = GroupStatus.Selected;
                }

                List <IRegion> children = new List <IRegion>();
                GetWidgetChildren(newGroup, children);
                if (children.Count < 1 || vmGroup == null)
                {
                    continue;
                }
                all.Add(vmGroup);

                foreach (IRegion item in children)
                {
                    WidgetViewModBase vmChild = WidgetFactory.CreateWidget(item);
                    if (vmChild == null)
                    {
                        continue;
                    }

                    vmChild.IsGroup    = false;
                    vmChild.ParentID   = newGroup.Guid;
                    vmChild.IsSelected = false;
                    vmGroup.AddChild(vmChild);
                    all.Add(vmChild);
                }
            }
            return(all);
        }