Example #1
0
        /// <summary>
        /// This method is for debugging purposes
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public FormObject GetByPath(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return(this);
            }

            int    divider = path.IndexOf('|');
            string index   = divider >= 0 ? path.Substring(0, divider) : path;

            int i;

            if (!int.TryParse(index, out i) || i >= Children.Count)
            {
                return(null);
            }

            FormObject            child     = Children [i];
            FormDrawableContainer container = child as FormDrawableContainer;

            if (container != null)
            {
                return(container.GetByPath(divider >= 0 && divider < path.Length - 1 ?
                                           path.Substring(divider + 1) : string.Empty));
            }

            return(child);
        }
        public FormDrawableObject GetParentBelow(FormDrawableContainer newParent)
        {
            FormObject currentParent = this;

            while (currentParent != null)
            {
                if (newParent.Children.Contains(currentParent))
                {
                    return((FormDrawableObject)currentParent);
                }
                currentParent = currentParent.Parent;
            }
            return(this);
        }
        protected virtual void QueueAllocateUp(bool reallocateCurrent = true)
        {
            if (reallocateCurrent)
            {
                IsAllocated = false;
            }

            FormDrawableContainer container = parent as FormDrawableContainer;

            if (container != null)
            {
                container.QueueAllocateUp();
            }
        }
        public virtual FormDrawableContainer GetAllowedParent(FormDrawableContainer parentToCheck)
        {
            FormDrawableContainer currentParent = parentToCheck;

            while (currentParent != null)
            {
                Type type = currentParent.GetType();
                if (GetAllowedParentTypes().Any(allowedParentType => type == allowedParentType || type.IsSubclassOf(allowedParentType)))
                {
                    return(currentParent);
                }

                currentParent = (FormDrawableContainer)currentParent.Parent;
            }
            return(null);
        }
Example #5
0
        public override FormDrawableContainer GetAllowedParent(FormDrawableContainer parentToCheck)
        {
            if (!(parentToCheck is TableCell))
            {
                return(null);
            }
            FormDrawableContainer currentParent = parentToCheck;

            while (currentParent != null)
            {
                if (currentParent == Parent.Parent)
                {
                    return(parentToCheck);
                }
                currentParent = (FormDrawableContainer)currentParent.Parent;
            }
            return(null);
        }
Example #6
0
        private bool IsPreviousSiblingPageBreak()
        {
            FormDrawableContainer container = Parent as FormDrawableContainer;

            if (container != null)
            {
                int index = container.Children.IndexOf(this);
                if (index > 0)
                {
                    Section section = container.Children [index - 1] as Section;
                    if (section != null && section.SectionType == Appearance.PageBreak)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #7
0
        public virtual void QueueCalculateDown(bool annulCalculatedSize = false)
        {
            if (!isCalculated)
            {
                return;
            }

            foreach (FormDrawableObject drawable in Children)
            {
                if (annulCalculatedSize)
                {
                    drawable.CalculatedSize.Width = drawable.CalculatedSize.Height = 0;
                }

                FormDrawableContainer container = drawable as FormDrawableContainer;
                if (container != null)
                {
                    container.QueueCalculateDown(annulCalculatedSize);
                }
            }

            isCalculated = false;
        }
        protected virtual bool ResolveDistribution(PointD start, SizeD size)
        {
            PageSettings pSettings = DocumentHelper.CurrentPageSettings;

            if (isDistributed || pSettings.Width.IsZero())
            {
                return(false);
            }

            SizeD startOffset = new SizeD();
            SizeD endOffset   = new SizeD();

            if (Parent != null)
            {
                FormDrawableContainer container = Parent as FormDrawableContainer;
                if (container == null)
                {
                    throw new Exception("The parent control is not a container.");
                }

                PointD contentStart = container.GetContentStart();
                startOffset.Width  = contentStart.X;
                startOffset.Height = contentStart.Y;

                // If this is not the last child in the parent object
                // add the inner offset else add the ending offset
                if (ParentPosition < container.Children.Count - 1)
                {
                    switch (container.ChildDistribution)
                    {
                    case ObjectStyle.ChildDistribution.Horizontal:
                        endOffset.Width = Math.Max(container.Style.InnerVerticalBorder ?? 0, container.Style.InnerHSpacing ?? 0);
                        break;

                    case ObjectStyle.ChildDistribution.Vertical:
                        endOffset.Height = Math.Max(container.Style.InnerHorizontalBorder ?? 0,
                                                    container.Style.InnerVSpacing ?? 0);
                        break;
                    }
                }
                else
                {
                    PointD contentEnd = container.GetContentEnd();
                    endOffset.Width  = contentEnd.X;
                    endOffset.Height = contentEnd.Y;
                }
            }

            bool ret = false;

            allocatedHPageFill       = 0f;
            distribution.LeftColumn  = Math.Max((int)start.X + 1, 0) / (int)pSettings.Width;
            distribution.RightColumn = Math.Max((int)(start.X + size.Width + endOffset.Width - 1), 0) / (int)pSettings.Width;
            if (distribution.LeftColumn != distribution.RightColumn && AllowHorizontalBreak && !style.AllowHBreak)
            {
                distribution.LeftColumn++;
                allocatedHPageFill = pSettings.Width - start.X % pSettings.Width;
                ret = true;
            }
            if (distribution.LeftColumn > distribution.RightColumn)
            {
                distribution.LeftColumn = distribution.RightColumn;
            }

            allocatedVPageFill    = 0f;
            distribution.UpperRow = Math.Max((int)start.Y + 1, 0) / (int)pSettings.Height;
            distribution.LowerRow = Math.Max((int)(start.Y + size.Height + endOffset.Height - 1), 0) / (int)pSettings.Height;
            if (distribution.UpperRow != distribution.LowerRow && AllowVerticalBreak && !style.AllowVBreak)
            {
                distribution.UpperRow++;
                allocatedVPageFill = pSettings.Height - start.Y % pSettings.Height;
                ret = true;
            }
            if (distribution.UpperRow > distribution.LowerRow)
            {
                distribution.UpperRow = distribution.LowerRow;
            }

            isDistributed = true;
            return(ret);
        }