public void PopulateGTList() { WorkspaceViewModel wvm = WorkspaceViewModel.Instance; List<string> checkList = new List<string>(); List<string> blackList = new List<string>(); //Blacklist the following pages: 3, 18, 19, 255, 100 //foreach (PageType pt in wvm.PageList) //{ // if ( // pt.PageTypeID.Equals("3") || // pt.PageTypeID.Equals("18") || // pt.PageTypeID.Equals("19") || // pt.PageTypeID.Equals("255") || // pt.PageTypeID.Equals("100") // ) // { // foreach (GroupTypeOrder gto in pt.GroupTypeOrders) // { // blackList.Add(gto.GroupTypeID); // } // } //} //foreach (PageType pt in wvm.PageList) //{ // foreach (GroupTypeOrder gto in pt.GroupTypeOrders) // { // if (!gto.GroupTypeID.Equals("60") && !gto.GroupTypeID.Equals("58") && !blackList.Exists(x => x.Equals(gto.GroupTypeID)) && !checkList.Exists(x => x.Equals(gto.GroupTypeID))) // { // ToolboxGroup tbGroup = new ToolboxGroup(); // tbGroup.Group = gto.Group; // GTList.Add(tbGroup); // //GTList.Add(gto.Group); // checkList.Add(gto.GroupTypeID); // } // } //} foreach (PageType pt in wvm.PageList) { // Blacklisted pages: 3, 18, 19, 255, 100 if ( !pt.PageTypeID.Equals("3") && !pt.PageTypeID.Equals("18") && !pt.PageTypeID.Equals("19") && !pt.PageTypeID.Equals("255") && !pt.PageTypeID.Equals("100") ) { foreach (GroupTypeOrder gto in pt.GroupTypeOrders) { if (!gto.GroupTypeID.Equals("60") && !gto.GroupTypeID.Equals("58")) { int i = 0; bool alreadyExist = false; while (i < checkList.Count && !alreadyExist) { if (checkList[i].Equals(gto.GroupTypeID)) alreadyExist = true; i++; } if (!alreadyExist) { ToolboxGroup tbGroup = new ToolboxGroup(); tbGroup.Group = gto.Group; GTList.Add(tbGroup); //GTList.Add(gto.Group); checkList.Add(gto.GroupTypeID); } } } } } SetupToolBoxItemCollectionView(); }
void HandleToolboxGroupDrop(ToolboxGroup tbg) { GroupTypeOrder targetGroupTypeOrder = MyGroupTypeOrder; GroupType draggedGroupType = tbg.Group; GTViewModel.InsertGroup(targetGroupTypeOrder, draggedGroupType); }
///// <summary> ///// Creates a new group on a the page ///// </summary> ///// <param name="pageTypeId">The id for the selected page</param> ///// <param name="languageId">The selected language of the application</param> ///// <param name="groupOrder">The group order number on the selected page</param> ///// <param name="englishTranslationText">The english group name</param> ///// <param name="danishTranslationText">The danish group name</param> //public void CreateGroup(string pageTypeId, string languageId, double groupOrder, string englishTranslationText, string danishTranslationText) //{ // GroupTypeOrder gtOrder = new GroupTypeOrder(); // GroupType groupType = new GroupType(); // //Create new GroupTypeOrder // gtOrder.DepartmentID = "-1"; // gtOrder.PageTypeID = pageTypeId; // int highestId = 0; // foreach (PageType page in PageList) // { // int index = 0; // while (index < page.GroupTypeOrders.Count) // { // if (Convert.ToInt32(page.GroupTypeOrders[index].GroupTypeID) > highestId) // { // highestId = Convert.ToInt32(page.GroupTypeOrders[index].GroupTypeID); // } // index++; // } // } // gtOrder.GroupTypeID = (highestId + 1).ToString(); // gtOrder.GroupOrder = groupOrder; // //Create new GroupType // groupType.GroupTypeID = (highestId + 1).ToString(); // groupType.DanishTranslationText = danishTranslationText; // groupType.EnglishTranslationText = englishTranslationText; // groupType.LanguageID = languageId; // string hej = englishTranslationText.Replace(" ", string.Empty); // int i = 1; // foreach (PageType page in PageList) // { // while ((from a in page.GroupTypeOrders where a.Group.ResourceType.Equals(hej + i) select a).Any()) // { // i++; // } // } // hej = hej + i; // groupType.ResourceType = hej; // groupType.ResourceID = (_groupCounter + 1).ToString(); // _groupCounter++; // groupType.ResourceTypeID = "1"; // //Reference GroupTypeOrder with GroupType // gtOrder.Group = groupType; // int hello = 0; // while (hello < PageList.Count) // { // if (PageList[hello].PageTypeID.Equals(pageTypeId)) // { // PageList[hello].GroupTypeOrders.Add(gtOrder); // } // hello++; // } //} /// <summary> /// Creates a new group on a the page /// </summary> /// <param name="pageTypeId">The id for the selected page</param> /// <param name="englishTranslationText">The english group name</param> /// <param name="danishTranslationText">The danish group name</param> /// <param name="departmentList">The selected departments the group is in</param> public void CreateGroup(string pageTypeId, string englishTranslationText, string danishTranslationText, List<string> departmentList) { GroupType groupType = new GroupType(); //Create new GroupTypeOrder int highestId = 0; foreach (PageType page in PageList) { int highestIdOnPage = Convert.ToInt32(page.GroupTypeOrders.Max(x => x.GroupTypeID)); if (highestIdOnPage > highestId) highestId = highestIdOnPage; //int index = 0; //while (index < page.GroupTypeOrders.Count) //{ // if (Convert.ToInt32(page.GroupTypeOrders[index].GroupTypeID) > highestId) // { // highestId = Convert.ToInt32(page.GroupTypeOrders[index].GroupTypeID); // } // index++; //} } ObservableCollection<GroupTypeOrder> groupTypeOrderCollection = PageList.First(x => x.PageTypeID.Equals(pageTypeId)).GroupTypeOrders; GroupTypeOrder gtoCompare = groupTypeOrderCollection.Last(); //Create new GroupType groupType.GroupTypeID = (highestId + 1).ToString(); groupType.DanishTranslationText = danishTranslationText; groupType.EnglishTranslationText = englishTranslationText; groupType.LanguageID = gtoCompare.Group.LanguageID; string hej = englishTranslationText.Replace(" ", string.Empty); int i = 1; foreach (PageType page in PageList) { while ((from a in page.GroupTypeOrders where a.Group.ResourceType.Equals(hej + i) select a).Any()) { i++; } } hej = hej + i; groupType.ResourceType = hej; groupType.ResourceID = (_groupCounter + 1).ToString(); _groupCounter++; groupType.ResourceTypeID = "1"; //Reference GroupTypeOrder with GroupType ToolboxGroupsViewModel glvm = ToolboxGroupsViewModel.Instance; ToolboxGroup tbg = new ToolboxGroup(); tbg.Group = groupType; glvm.GTList.Add(tbg); //int hello = 0; //while (hello < PageList.Count) //{ // if (PageList[hello].PageTypeID.Equals(pageTypeId)) // { // PageList[hello].GroupTypeOrders.Add(gtOrder); // } // hello++; //} foreach (string departmentID in departmentList) { GroupTypeOrder clonedGto = new GroupTypeOrder(); clonedGto.DepartmentID = departmentID; clonedGto.Group = groupType; //clonedGto.GroupOrder = gtoCompare.GroupOrder + 1; clonedGto.GroupOrder = groupTypeOrderCollection.Max(x => x.GroupOrder) + 1; clonedGto.GroupTypeID = (highestId + 1).ToString(); clonedGto.PageTypeID = pageTypeId; groupTypeOrderCollection.Add(clonedGto); } }
public void ToolboxGroupsFilterList() { GroupType gt = new GroupType(); gt.DanishTranslationText = "Øre, næse og hals"; gt.EnglishTranslationText = "Ear, nose and throat"; gt.GroupTypeID = "10"; gt.ItemOrder = null; gt.LanguageID = "2"; gt.ResourceID = ""; gt.ResourceType = null; gt.ResourceTypeID = null; ToolboxGroup tbGroup = new ToolboxGroup(); tbGroup.Group = gt; GroupType gt2 = new GroupType(); gt2.DanishTranslationText = "Risikofaktorer for infektion"; gt2.EnglishTranslationText = "Risk Factors for infection"; gt2.GroupTypeID = "10"; gt2.ItemOrder = null; gt2.LanguageID = "2"; gt2.ResourceID = ""; gt2.ResourceType = null; gt2.ResourceTypeID = null; ToolboxGroup tbGroup2 = new ToolboxGroup(); tbGroup2.Group = gt2; glvm.GTList.Add(tbGroup); glvm.GTList.Add(tbGroup2); glvm.LanguageID = "1"; glvm.SetupToolBoxItemCollectionView(); glvm.FilterString = "Risk Factors"; //ifvm.DesignItemsView = CollectionViewSource.GetDefaultView(ifvm.ToolboxItemList); Assert.IsTrue(glvm.DesignItemsView.Contains(tbGroup2)); Assert.IsFalse(glvm.DesignItemsView.Contains(tbGroup)); }