Пример #1
0
        /// <summary>
        /// build the tree structure out of the given assembly
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="position"></param>
        /// <param name="level"></param>
        private PVFactorioItemContainer buildTreeStructure(IFactorioAssembly assembly, int position = 0, int level = 0)
        {
            PVFactorioItemContainer container = new PVFactorioItemContainer(assembly, level, this.Settings, this.FactorioItemContainers);

            if (level == 0)
            {
                m_rootContainer = container;
            }

            container.Left         = position;
            container.SubTreeWidth = 0;

            PVFactorioItemContainer firstSubContainer = null;
            PVFactorioItemContainer lastSubContainer  = null;

            for (int i = 0; i < container.Assembly.SubAssembly.Count; i++)
            {
                // Build a branch for the current subassembly and position it right to the last subassembly
                PVFactorioItemContainer currentSubContainer = buildTreeStructure(
                    container.Assembly.SubAssembly[i],
                    container.Left + container.SubTreeWidth,
                    level + 1);

                if (firstSubContainer == null)
                {
                    firstSubContainer = currentSubContainer;
                }

                lastSubContainer = currentSubContainer;

                Lines.Add(new PVLine(container, currentSubContainer));

                container.SubTreeWidth += currentSubContainer.SubTreeWidth;
            }

            if (firstSubContainer != null)
            {
                container.Left = (lastSubContainer.Left - firstSubContainer.Left) / 2 + firstSubContainer.Left;
            }
            else
            {
                container.SubTreeWidth = this.Settings.ItemContainerWidth + this.Settings.WidthOffset;
            }



            FactorioItemContainers.Add(container);

            return(container);
        }
Пример #2
0
 /// <summary>
 /// Creates a line from a image in a higher level to a lower level image.
 /// </summary>
 /// <param name="from">the line starts at the bottom middle of this image</param>
 /// <param name="to">the line stop at the top middle of this image</param>
 public PVLine(PVFactorioItemContainer from, PVFactorioItemContainer to)
 {
     m_from = from;
     m_to   = to;
 }