internal ReportComponentCollection SortByTop()
        {
            ReportComponentCollection result = new ReportComponentCollection();

            CopyTo(result);
            result.InnerList.Sort(new TopComparer());
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BandBase"/> class with default settings.
 /// </summary>
 public BandBase()
 {
     objects           = new ReportComponentCollection(this);
     guides            = new FloatCollection();
     beforeLayoutEvent = "";
     afterLayoutEvent  = "";
     outlineExpression = "";
     CanBreak          = false;
     ShiftMode         = ShiftMode.Never;
     if (BaseName.EndsWith("Band"))
     {
         BaseName = ClassName.Remove(ClassName.IndexOf("Band"));
     }
     SetFlags(Flags.CanMove | Flags.CanChangeOrder | Flags.CanChangeParent | Flags.CanCopy | Flags.CanGroup, false);
     FlagUseStartNewPage = true;
     FlagCheckFreeSpace  = true;
 }
Beispiel #3
0
        /// <inheritdoc/>
        public override void RestoreState()
        {
            OnAfterPrint(EventArgs.Empty);
            base.RestoreState();
            while (Objects.Count > savedOriginalObjectsCount)
            {
                Objects[Objects.Count - 1].Dispose();
            }
            SetRunning(false);

            ReportComponentCollection collection_clone = new ReportComponentCollection();

            Objects.CopyTo(collection_clone);
            foreach (ReportComponentBase obj in collection_clone)
            {
                obj.OnAfterPrint(EventArgs.Empty);
                obj.RestoreState();
                obj.SetRunning(false);
            }
        }
Beispiel #4
0
        /// <inheritdoc/>
        public override float CalcHeight()
        {
            OnBeforeLayout(EventArgs.Empty);

            // sort objects by Top
            ReportComponentCollection sortedObjects = Objects.SortByTop();

            // calc height of each object
            float[] heights = new float[sortedObjects.Count];
            for (int i = 0; i < sortedObjects.Count; i++)
            {
                ReportComponentBase obj = sortedObjects[i];
                float height            = obj.Height;
                if (obj.Visible && (obj.CanGrow || obj.CanShrink))
                {
                    float height1 = obj.CalcHeight();
                    if ((obj.CanGrow && height1 > height) || (obj.CanShrink && height1 < height))
                    {
                        height = height1;
                    }
                }
                heights[i] = height;
            }

            // calc shift amounts
            float[] shifts = new float[sortedObjects.Count];
            for (int i = 0; i < sortedObjects.Count; i++)
            {
                ReportComponentBase parent = sortedObjects[i];
                float shift = heights[i] - parent.Height;
                if (shift == 0)
                {
                    continue;
                }

                for (int j = i + 1; j < sortedObjects.Count; j++)
                {
                    ReportComponentBase child = sortedObjects[j];
                    if (child.ShiftMode == ShiftMode.Never)
                    {
                        continue;
                    }

                    if (child.Top >= parent.Bottom - 1e-4)
                    {
                        if (child.ShiftMode == ShiftMode.WhenOverlapped &&
                            (child.Left > parent.Right - 1e-4 || parent.Left > child.Right - 1e-4))
                        {
                            continue;
                        }

                        float parentShift = shifts[i];
                        float childShift  = shifts[j];
                        if (shift > 0)
                        {
                            childShift = Math.Max(shift + parentShift, childShift);
                        }
                        else
                        {
                            childShift = Math.Min(shift + parentShift, childShift);
                        }
                        shifts[j] = childShift;
                    }
                }
            }

            // update location and size of each component, calc max height
            float maxHeight = 0;

            for (int i = 0; i < sortedObjects.Count; i++)
            {
                ReportComponentBase obj      = sortedObjects[i];
                DockStyle           saveDock = obj.Dock;
                obj.Dock   = DockStyle.None;
                obj.Height = heights[i];
                obj.Top   += shifts[i];
                if (obj.Visible && obj.Bottom > maxHeight)
                {
                    maxHeight = obj.Bottom;
                }
                obj.Dock = saveDock;
            }

            if ((CanGrow && maxHeight > Height) || (CanShrink && maxHeight < Height))
            {
                Height = maxHeight;
            }

            // perform grow to bottom
            foreach (ReportComponentBase obj in Objects)
            {
                if (obj.GrowToBottom)
                {
                    obj.Height = Height - obj.Top;
                }
            }

            OnAfterLayout(EventArgs.Empty);
            return(Height);
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <b>ContainerObject</b> class with default settings.
 /// </summary>
 public ContainerObject()
 {
     objects           = new ReportComponentCollection(this);
     beforeLayoutEvent = "";
     afterLayoutEvent  = "";
 }