public void CreateSpecialItems()
        {
            List<ToolboxItem> toolboxItemList = new List<ToolboxItem>();

            ToolboxItem tbiNewLine = new ToolboxItem();
            ItemType itNewLine = new ItemType();
            itNewLine.DesignID = "198";
            itNewLine.Header = "<NewLineItem>";
            tbiNewLine.ItemType = itNewLine;

            ToolboxItem tbiEmptyField = new ToolboxItem();
            ItemType itEmptyField = new ItemType();
            itEmptyField.DesignID = "197";
            itEmptyField.Header = "<EmptyField>";
            tbiEmptyField.ItemType = itEmptyField;

            toolboxItemList.Add(tbiNewLine);
            toolboxItemList.Add(tbiEmptyField);

            SpecialItemsView = CollectionViewSource.GetDefaultView(toolboxItemList);
        }
        private void CreateToolboxItems()
        {
            WorkspaceViewModel wvm = WorkspaceViewModel.Instance;
            foreach (ItemType itemType in wvm.ItemTypeList)
            {
                ToolboxItem tbi = new ToolboxItem();
                if(itemType != null && !itemType.DesignID.Equals("197") && !itemType.DesignID.Equals("198"))
                {
                    tbi.ItemType = itemType;
                    ToolboxItemList.Add(tbi);
                }

            }
        }
        /// <summary>
        /// Handles drop logic for NewLineItem from toolbox
        /// </summary>
        /// <param name="dropTargetItemTypeOrder"></param>
        /// <param name="tbi"></param>
        /// <param name="gt"></param>
        public void ToolboxSpecialNewLineItemDrop(ItemTypeOrder dropTargetItemTypeOrder, ToolboxItem tbi, GroupType gt)
        {
            CheckForNewLineItem(dropTargetItemTypeOrder);
            ItemTypeOrder itemTypeOrder = new ItemTypeOrder();
            itemTypeOrder.DesignID = tbi.ItemType.DesignID;
            ItemType itemType = new ItemType();
            itemType.DesignID = tbi.ItemType.DesignID;
            itemType.Header = tbi.ItemType.Header;
            itemTypeOrder.ItemOrder = dropTargetItemTypeOrder.ItemOrder;
            itemType.DanishTranslationText = tbi.ItemType.DanishTranslationText;
            itemType.EnglishTranslationText = tbi.ItemType.EnglishTranslationText;
            itemType.LanguageID = tbi.ItemType.LanguageID;
            itemTypeOrder.GroupTypeID = gt.GroupTypeID;
            itemTypeOrder.IncludedTypeID = "1";
            itemTypeOrder.Item = itemType;

            int index = gt.ItemOrder.IndexOf(dropTargetItemTypeOrder);

            gt.ItemOrder.Insert(index, itemTypeOrder);
            int draggedIndex = gt.ItemOrder.IndexOf(itemTypeOrder);

            AdjustItemOrderNewLineItemDrop(gt, draggedIndex);
            //AdjustItemOrder(gt);
        }
 /// <summary>
 /// Handles drop logic for standard item from toolbox
 /// </summary>
 /// <param name="dropTargetItemTypeOrder"></param>
 /// <param name="tbi"></param>
 /// <param name="gt"></param>
 public void ToolboxItemDropOnStandardItem(ItemTypeOrder dropTargetItemTypeOrder, ToolboxItem tbi, GroupType gt)
 {
     ItemTypeOrder itemTypeOrder = new ItemTypeOrder();
     itemTypeOrder.DesignID = tbi.ItemType.DesignID;
     ItemType itemType = new ItemType { DesignID = tbi.ItemType.DesignID, Header = tbi.ItemType.Header };
     itemTypeOrder.ItemOrder = dropTargetItemTypeOrder.ItemOrder;
     itemType.DanishTranslationText = tbi.ItemType.DanishTranslationText;
     itemType.EnglishTranslationText = tbi.ItemType.EnglishTranslationText;
     itemType.LanguageID = tbi.ItemType.LanguageID;
     itemTypeOrder.GroupTypeID = gt.GroupTypeID;
     itemTypeOrder.IncludedTypeID = "1";
     itemTypeOrder.Item = itemType;
     int startPosition = gt.ItemOrder.IndexOf(dropTargetItemTypeOrder);
     MoveItemsForward(startPosition, itemTypeOrder, gt);
 }
 /// <summary>
 /// Handles drop logic on null field
 /// </summary>
 /// <param name="dropTargetItemTypeOrder"></param>
 /// <param name="tbi"></param>
 /// <param name="gt"></param>
 public void ToolboxItemDropOnNullField(ItemTypeOrder dropTargetItemTypeOrder, ToolboxItem tbi, GroupType gt)
 {
     dropTargetItemTypeOrder.DesignID = tbi.ItemType.DesignID;
     ItemType itemType = new ItemType();
     itemType.DesignID = tbi.ItemType.DesignID;
     itemType.Header = tbi.ItemType.Header;
     itemType.DanishTranslationText = tbi.ItemType.DanishTranslationText;
     itemType.EnglishTranslationText = tbi.ItemType.EnglishTranslationText;
     itemType.LanguageID = tbi.ItemType.LanguageID;
     dropTargetItemTypeOrder.GroupTypeID = gt.GroupTypeID;
     dropTargetItemTypeOrder.IncludedTypeID = "1";
     dropTargetItemTypeOrder.Item = itemType;
     gt.ItemOrder.Add(dropTargetItemTypeOrder);
     GenerateEmptyFields(gt);
 }
 /// <summary>
 /// Handles drop logic on emptyfield
 /// </summary>
 /// <param name="dropTargetItemTypeOrder"></param>
 /// <param name="tbi"></param>
 /// <param name="gt"></param>
 public void ToolboxItemDropOnEmptyField(ItemTypeOrder dropTargetItemTypeOrder, ToolboxItem tbi, GroupType gt)
 {
     dropTargetItemTypeOrder.DesignID = tbi.ItemType.DesignID;
     dropTargetItemTypeOrder.Item.Header = tbi.ItemType.Header;
     dropTargetItemTypeOrder.Item.DanishTranslationText = tbi.ItemType.DanishTranslationText;
     dropTargetItemTypeOrder.Item.EnglishTranslationText = tbi.ItemType.EnglishTranslationText;
     dropTargetItemTypeOrder.Item.LanguageID = tbi.ItemType.LanguageID;
     dropTargetItemTypeOrder.GroupTypeID = gt.GroupTypeID;
     dropTargetItemTypeOrder.IncludedTypeID = "1";
 }
 /// <summary>
 /// Handles drop logic for items from toolbox. Drop logic depends on the type of the dropped item 
 /// </summary>
 /// <param name="gt"></param>
 /// <param name="tbi"></param>
 /// <param name="dropTargetItemTypeOrder"></param>
 public void HandleToolboxItemDrop(GroupType gt, ToolboxItem tbi, ItemTypeOrder dropTargetItemTypeOrder)
 {
     string dropTargetDesignID = dropTargetItemTypeOrder.DesignID;
     if (tbi.ItemType.DesignID.Equals("198") && dropTargetDesignID != null)
     {
         ToolboxSpecialNewLineItemDrop(dropTargetItemTypeOrder, tbi, gt);
     }
     if (dropTargetDesignID != null && !tbi.ItemType.DesignID.Equals("198") && !dropTargetDesignID.Equals("197"))
     {
         ToolboxItemDropOnStandardItem(dropTargetItemTypeOrder, tbi, gt);
     }
     if (dropTargetDesignID == null) //drop on null field
     {
         ToolboxItemDropOnNullField(dropTargetItemTypeOrder, tbi, gt);
     }
     if (dropTargetDesignID != null && dropTargetDesignID.Equals("197") && !tbi.ItemType.DesignID.Equals("198"))
     {
         ToolboxItemDropOnEmptyField(dropTargetItemTypeOrder, tbi, gt);
     }
 }
        /// <summary>
        /// Handles drop logic for items from a group. Drop logic depends on both drop target and dragged item
        /// </summary>
        /// <param name="gt"></param>
        /// <param name="targetItemType"></param>
        /// <param name="draggedItemType"></param>
        public void HandleDropAndDropBetweenItems(GroupType gt, ItemTypeOrder targetItemType, ItemTypeOrder draggedItemType)
        {
            if (!gt.Equals(Group)) //dropping an item from one group to another
            {
                ToolboxItem tbi = new ToolboxItem();
                RemoveItemTypeOrder(gt, draggedItemType);
                tbi.ItemType = draggedItemType.Item;
                HandleToolboxItemDrop(Group, tbi, targetItemType);
                GroupTypeOrderCollection.Sort(x => x.GroupOrder); //refresh all groups to show the changes
            }
            else
            {
                int draggedPosition = gt.ItemOrder.IndexOf(draggedItemType);
                double targetItemTypeNo = targetItemType.ItemOrder; //affected item
                int targetPosition = gt.ItemOrder.IndexOf(targetItemType);

                if (targetItemType != draggedItemType)
                {
                    gt.ItemOrder.Remove(draggedItemType);
                    if (targetItemType.DesignID == null && !draggedItemType.DesignID.Equals("198"))
                    {
                        AdjustItemOrder(gt);
                        draggedItemType.ItemOrder = targetItemType.ItemOrder;
                        gt.ItemOrder.Add(draggedItemType);
                        gt.ItemOrder.Sort(i => i.ItemOrder);
                        GenerateEmptyFields(gt);
                    }
                    else if (targetItemType.DesignID == null && draggedItemType.DesignID.Equals("198"))
                    {

                        draggedItemType.ItemOrder = targetItemType.ItemOrder;
                        gt.ItemOrder.Add(draggedItemType);
                        gt.ItemOrder.Sort(i => i.ItemOrder);
                        GenerateEmptyFields(gt);
                        AdjustItemOrder(gt);

                    }

                    else if (draggedItemType.DesignID.Equals("198"))
                    {
                        if (draggedItemType.ItemOrder > targetItemType.ItemOrder)
                        {
                            gt.ItemOrder.Insert(targetPosition, draggedItemType);
                            draggedItemType.ItemOrder = targetItemTypeNo;
                            gt.ItemOrder.Sort(i => i.ItemOrder);
                            AdjustItemOrder(gt);
                        }
                        else
                        {
                            draggedItemType.ItemOrder = targetItemTypeNo;

                            //gt.ItemOrder.Insert(targetPosition - 1, draggedItemType);
                            gt.ItemOrder.Insert(targetPosition - 1, draggedItemType);
                            gt.ItemOrder.Sort(i => i.ItemOrder);
                            GenerateEmptyFields(gt);
                            AdjustItemOrder(gt);
                        }
                        //GenerateEmptyFields(gt);
                        gt.ItemOrder.Sort(i => i.ItemOrder);
                    }

                    else if (targetItemType.DesignID != null && draggedItemType.DesignID != null /*&& !draggedItemType.DesignID.Equals("198")*/)
                    {
                        if (draggedItemType.ItemOrder > targetItemType.ItemOrder)
                        {
                            gt.ItemOrder.Insert(targetPosition, draggedItemType);
                            draggedItemType.ItemOrder = targetItemTypeNo;
                        }
                        else
                        {
                            if (gt.ItemOrder.Count != targetPosition)
                            {
                                draggedItemType.ItemOrder = targetItemTypeNo;
                                gt.ItemOrder.Insert(targetPosition, draggedItemType);
                            }
                            else
                            {
                                draggedItemType.ItemOrder = targetItemTypeNo;
                                gt.ItemOrder.Add(draggedItemType);
                            }
                        }
                        AdjustItemOrder(gt, targetPosition, draggedPosition);

                        GenerateEmptyFields(gt);
                        gt.ItemOrder.Sort(i => i.ItemOrder);
                    }
                }
            }
        }
Esempio n. 9
0
        public void ToolboxItemsFilterList()
        {
            ToolboxItem tbi = new ToolboxItem();
            ItemType it = new ItemType();
            it.DesignID = "123";
            it.DanishTranslationToolTip = "ToolTip - Dette er en test";
            it.EnglishTranslationToolTip = "ToolTip - This is a test";
            it.DanishTranslationText = "Dette er en test";
            it.EnglishTranslationText = "This is a test";
            it.LanguageID = "2";
            tbi.ItemType = it;

            ToolboxItem tbi2 = new ToolboxItem();
            ItemType it2 = new ItemType();
            it2.DesignID = "123";
            it2.DanishTranslationToolTip = "ToolTip - Dette er endnu en test";
            it2.EnglishTranslationToolTip = "ToolTip - This is another test";
            it2.DanishTranslationText = "Header - Dette er endnu en test";
            it2.EnglishTranslationText = "Header - This is another test";
            it2.LanguageID = "2";
            tbi2.ItemType = it2;

            ifvm.ToolboxItemList.Add(tbi);
            ifvm.ToolboxItemList.Add(tbi2);
            ifvm.LanguageID = "2";
            ifvm.SetupToolBoxItemCollectionView();
            ifvm.FilterString = "endnu";
            Assert.IsTrue(ifvm.DesignItemsView.Contains(tbi2));
            Assert.IsFalse(ifvm.DesignItemsView.Contains(tbi));
        }