Exemplo n.º 1
0
        public void DropToolBoxGroupOnPageByDropZone()
        {
            glvm.PopulateGTList();
            List <ToolboxGroup> tbgList = glvm.DesignItemsView.Cast <ToolboxGroup>().ToList();
            ToolboxGroup        tbg     = tbgList.Find(x => x.Group.GroupTypeID.Equals("16"));
            ObservableCollection <GroupTypeOrder> gtoList = wvm.PageList[14].GroupTypeOrders; // page 15

            gtvm.GroupTypeOrderCollection = gtoList;
            gtvm.AdjustGroupOrder();

            GroupType gt = tbg.Group;

            gtvm.InsertGroupLast(gt, "15");
            Assert.AreEqual(gtoList.Last().Group, tbg.Group);
            Assert.AreEqual(gtoList.Last().GroupOrder, gtoList.Count);
        }
        private void dropZoneToolboxGroup_Drop(object sender, DragEventArgs e)
        {
            ListBoxItem        lbi        = (ListBoxItem)e.Data.GetData("System.Windows.Controls.ListBoxItem");
            ToolboxGroup       tbg        = (ToolboxGroup)lbi.DataContext;
            WorkspaceViewModel wvm        = WorkspaceViewModel.Instance;
            string             pageTypeID = wvm.SelectedPage;
            ObservableCollection <PageType>       pageList = wvm.PageList;
            ObservableCollection <GroupTypeOrder> GroupTypeOrderCollection = pageList.First(x => x.PageTypeID.Equals(pageTypeID)).GroupTypeOrders;

            if (GroupTypeOrderCollection.Any(x => x.Group.GroupTypeID.Equals(tbg.Group.GroupTypeID)))
            {
                MessageBox.Show("The group already exists", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                GroupType           gt   = tbg.Group;
                GroupTableViewModel gtvm = new GroupTableViewModel();
                gtvm.GroupTypeOrderCollection = GroupTypeOrderCollection;
                gtvm.InsertGroupLast(gt, pageTypeID);
            }
        }