コード例 #1
0
        public GroupViewModel CreateGroupRender(IGroup targetGroup, CompositeCommand cmds = null)
        {
            //create group element
            GroupViewModel NewGroupVM = WidgetFactory.CreateGroup(targetGroup) as GroupViewModel;

            //remove the older inner group
            List <GroupViewModel> AllGroups = items.OfType <GroupViewModel>().Where(c => c.IsGroup == true).ToList <GroupViewModel>();

            foreach (GroupViewModel it in AllGroups)
            {
                if (NewGroupVM.IsChild(it.widgetGID, true))
                {
                    it.IsSelected = false;
                    _selectionService.RemoveWidget(it);
                    items.Remove(it);
                }
            }


            //initialize all elements in new group
            foreach (WidgetViewModBase wdg in Items)
            {
                if (true == NewGroupVM.IsChild(wdg.widgetGID, false))
                {
                    wdg.ParentID   = NewGroupVM.widgetGID;
                    wdg.IsGroup    = false;
                    wdg.IsSelected = false;
                    NewGroupVM.AddChild(wdg);
                }
            }

            #region Reset Zorder

            // We got a crash report which was caused by  the exception System.InvalidOperationException from
            // System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable`1<Int32>), so make sure WidgetChildren has element first.
            // See http://bts1.nhncorp.com/nhnbts/browse/DSTUDIO-1679
            SetTargetObject2Front(NewGroupVM.WidgetChildren, cmds);
            //SetGroupTargetObjectContinue(, cmds, NewGroupVM);

            #endregion

            //UI Render the new group
            NewGroupVM.IsSelected = true;
            NewGroupVM.Status     = GroupStatus.Selected;
            //NewGroupVM.ZOrder = -3;
            Items.Add(NewGroupVM);
            NewGroupVM.Refresh();

            _ListEventAggregator.GetEvent <GroupChangedEvent>().Publish(true);
            return(NewGroupVM);
        }
コード例 #2
0
        public void UnGroup(GroupViewModel groupVM)
        {
            GroupViewModel           targetVM       = groupVM;
            List <WidgetViewModBase> WidgetChildren = targetVM.WidgetChildren;

            foreach (WidgetViewModBase item in WidgetChildren)
            {
                item.ParentID = Guid.Empty;
            }

            IGroups ChildGroups = targetVM.GroupChildren;
            //======================================================render the group
            //Create the external Groups
            List <WidgetViewModBase> GroupVMs = new List <WidgetViewModBase>();

            foreach (IGroup it in ChildGroups)
            {
                WidgetViewModBase vmItem = WidgetFactory.CreateGroup(it);
                if (vmItem == null)
                {
                    return;
                }
                vmItem.IsGroup = true;
                GroupVMs.Add(vmItem);
            }

            //Remove the parent group
            targetVM.IsSelected = false;
            _selectionService.RemoveWidget(targetVM);
            Items.Remove(targetVM);

            //Initialize the new Group
            //if (GroupVMs.Count <= 0)
            //    return;
            foreach (WidgetViewModBase wdg in Items)
            {
                foreach (GroupViewModel group in GroupVMs)
                {
                    if (true == group.IsChild(wdg.widgetGID, false))
                    {
                        wdg.ParentID   = group.widgetGID;
                        wdg.IsGroup    = false;
                        wdg.IsSelected = false;
                        group.AddChild(wdg);
                    }
                }
            }

            //UI Render the Groups
            foreach (GroupViewModel group in GroupVMs)
            {
                group.Status = GroupStatus.Selected;
                Items.Add(group);
                group.Refresh();
            }
            //===========================================


            //Select new childreb
            foreach (WidgetViewModBase item in WidgetChildren)
            {
                if (item.ParentID == Guid.Empty)
                {
                    item.IsSelected = true;
                    item.IsGroup    = false;
                }
            }

            //Last
            _model.UnGroup(groupVM.WidgetID);
            _ListEventAggregator.GetEvent <GroupChangedEvent>().Publish(false);
        }
コード例 #3
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);
        }