Пример #1
0
 public virtual bool CanDropBefore(BaseProjectNode node)
 {
     return(false);
 }
Пример #2
0
 public virtual bool CanDropAfter(BaseProjectNode node)
 {
     return(false);
 }
Пример #3
0
        protected void AutoGroupElements(IEnumerable <PartElement> elements, string groupTitle, int groupWhen, int maxGroupSize, bool groupOnSameLevel = false)
        {
            int totalElements = elements.Count();

            if (totalElements > groupWhen)
            {
                BaseProjectNode groupNode = this;

                if (!groupOnSameLevel)
                {
                    groupNode = new BaseProjectNode(Project, groupTitle)
                    {
                        IsDirty = false
                    };
                    Childrens.Add(groupNode);
                }

                //var parentNode = groupNode.Parent;

                if (totalElements > maxGroupSize)
                {
                    int remaining = totalElements;
                    int currIdx   = 0;

                    while (remaining > 0)
                    {
                        int takeCount = Math.Min(remaining, maxGroupSize);

                        string rangeText = string.Empty;
                        if (takeCount / (double)maxGroupSize < 0.5)
                        {
                            rangeText = string.Format(ModelLocalizations.NodeRangeFormat2, currIdx + 1);
                        }
                        else
                        {
                            rangeText = string.Format(ModelLocalizations.NodeRangeFormat1, currIdx + 1, currIdx + takeCount);
                        }

                        var rangeNode = new ElementGroupNode(Project, rangeText);

                        if (groupOnSameLevel)
                        {
                            rangeNode.Text = groupTitle + " " + rangeNode.Text;
                        }

                        rangeNode.Elements.AddRange(elements.Skip(currIdx).Take(maxGroupSize));
                        groupNode.Childrens.Add(rangeNode);
                        currIdx   += takeCount;
                        remaining -= takeCount;
                    }
                }
                else
                {
                    foreach (var elem in elements)
                    {
                        groupNode.Childrens.Add(ProjectElementNode.CreateDefault(elem));
                    }
                }
            }
            else
            {
                foreach (var elem in elements)
                {
                    Childrens.Add(ProjectElementNode.CreateDefault(elem));
                }
            }
        }