/// <inheritdoc/> public override bool Break(BreakableComponent breakTo) { using (Graphics g = FRichTextBox.CreateGraphics()) { // determine number of characters fit in the bounds. Set less height to prevent possible data loss. RectangleF textRect = new RectangleF(0, 0, Width - Padding.Horizontal, Height - Padding.Vertical - 20); Graphics measureGraphics = Report == null ? g : Report.PrintSettings.MeasureGraphics; if (measureGraphics == null) { measureGraphics = g; } int textStart = ActualTextStart; int textLength = ActualTextLength != 0 ? ActualTextLength : FRichTextBox.TextLength - textStart; int charsFit = FRichTextBox.FormatRange(g, measureGraphics, textRect, textStart, textStart + textLength, true) - textStart; if (charsFit <= 0) { return(false); } // perform break if (breakTo != null) { RichObject richTo = breakTo as RichObject; richTo.Text = Text; richTo.ActualTextStart = textStart + charsFit; ActualTextLength = charsFit; } return(true); } }
/// <inheritdoc/> public override void Assign(Base source) { base.Assign(source); BreakableComponent src = source as BreakableComponent; CanBreak = src.CanBreak; BreakTo = src.BreakTo; }
/// <inheritdoc/> public override bool Break(BreakableComponent breakTo) { string breakText = BreakText(); if (breakText != null && breakTo != null) { (breakTo as TextObject).Text = breakText; } return(breakText != null); }
/// <summary> /// Initializes a new instance of the <b>BreakableComponentMenu</b> class with default settings. /// </summary> public BreakableComponentMenu(Designer designer) : base(designer) { FSelection = Designer.SelectedObjects; miCanBreak = CreateMenuItem(Res.Get("ComponentMenu,BreakableComponent,CanBreak"), new EventHandler(miCanBreak_Click)); miCanBreak.AutoCheckOnClick = true; int insertPos = Items.IndexOf(miCanShrink); Items.Insert(insertPos + 1, miCanBreak); BreakableComponent component = FSelection[0] as BreakableComponent; miCanBreak.Enabled = !component.HasRestriction(Restrictions.DontModify); miCanBreak.Checked = component.CanBreak; }
/// <inheritdoc/> public override void Serialize(FRWriter writer) { BreakableComponent c = writer.DiffObject as BreakableComponent; base.Serialize(writer); if (CanBreak != c.CanBreak) { writer.WriteBool("CanBreak", CanBreak); } if (writer.SerializeTo != SerializeTo.Preview && writer.SerializeTo != SerializeTo.SourcePages && BreakTo != c.BreakTo) { writer.WriteRef("BreakTo", BreakTo); } }
/// <inheritdoc/> public override bool Break(BreakableComponent breakTo) { // first we find the break line. It's a minimum Top coordinate of the object that cannot break. float breakLine = Height; bool breakLineFound = true; do { breakLineFound = true; foreach (ReportComponentBase obj in Objects) { bool canBreak = true; if (obj.Top < breakLine && obj.Bottom > breakLine) { canBreak = false; BreakableComponent breakable = obj as BreakableComponent; if (breakable != null && breakable.CanBreak) { using (BreakableComponent clone = Activator.CreateInstance(breakable.GetType()) as BreakableComponent) { clone.AssignAll(breakable); clone.Height = breakLine - clone.Top; // to allow access to the Report clone.Parent = breakTo; canBreak = clone.Break(null); } } } if (!canBreak) { breakLine = Math.Min(obj.Top, breakLine); // enumerate objects again breakLineFound = false; break; } } }while (!breakLineFound); // now break the components int i = 0; while (i < Objects.Count) { ReportComponentBase obj = Objects[i]; if (obj.Bottom > breakLine) { if (obj.Top < breakLine) { BreakableComponent breakComp = Activator.CreateInstance(obj.GetType()) as BreakableComponent; breakComp.AssignAll(obj); breakComp.Parent = breakTo; breakComp.CanGrow = true; breakComp.CanShrink = false; breakComp.Height -= breakLine - obj.Top; breakComp.Top = 0; obj.Height = breakLine - obj.Top; (obj as BreakableComponent).Break(breakComp); } else { obj.Top -= breakLine; obj.Parent = breakTo; continue; } } i++; } Height = breakLine; breakTo.Height -= breakLine; return(Objects.Count > 0); }
public void AddLastToFooter(BreakableComponent breakTo) { float maxTop = (AllObjects[0] as ComponentBase).Top; foreach (ComponentBase obj in AllObjects) { if (obj.Top > maxTop && !(obj is DataFooterBand)) { maxTop = obj.Top; } } float breakLine = maxTop; List <ReportComponentBase> pasteList = new List <ReportComponentBase>(); foreach (ReportComponentBase obj in Objects) { if (obj.Bottom > breakLine) { pasteList.Add(obj); } } int itemsBefore = breakTo.AllObjects.Count; foreach (ReportComponentBase obj in pasteList) { if (obj.Top < breakLine) { BreakableComponent breakComp = Activator.CreateInstance(obj.GetType()) as BreakableComponent; breakComp.AssignAll(obj); breakComp.Parent = breakTo; breakComp.CanGrow = true; breakComp.CanShrink = false; breakComp.Height -= breakLine - obj.Top; breakComp.Top = 0; obj.Height = breakLine - obj.Top; (obj as BreakableComponent).Break(breakComp); } else { obj.Top -= breakLine; obj.Parent = breakTo; continue; } } float minTop = (breakTo.AllObjects[0] as ComponentBase).Top; float maxBottom = 0; for (int i = itemsBefore; i < breakTo.AllObjects.Count; i++) { if ((breakTo.AllObjects[i] as ComponentBase).Top < minTop && breakTo.AllObjects[i] is ReportComponentBase && !(breakTo.AllObjects[i] is Table.TableCell)) { minTop = (breakTo.AllObjects[i] as ComponentBase).Top; } } for (int i = itemsBefore; i < breakTo.AllObjects.Count; i++) { if ((breakTo.AllObjects[i] as ComponentBase).Bottom > maxBottom && breakTo.AllObjects[i] is ReportComponentBase && !(breakTo.AllObjects[i] is Table.TableCell)) { maxBottom = (breakTo.AllObjects[i] as ComponentBase).Bottom; } } for (int i = 0; i < itemsBefore; i++) { (breakTo.AllObjects[i] as ComponentBase).Top += maxBottom - minTop; } breakTo.Height += maxBottom - minTop; Height -= maxBottom - minTop; }
private void BreakTo_Disposed(object sender, EventArgs e) { FBreakTo = null; }
/// <summary> /// Breaks the contents of the object. /// </summary> /// <param name="breakTo">Object to put the part of content to that does not fit in this object. These two /// objects must have the same type.</param> /// <returns><b>true</b> if there is enough space in this object to display at least one text line.</returns> /// <remarks> /// <para> /// Do not call this method directly, it is used by the report engine. You should override it if /// you are writing a new FastReport object. /// </para> /// <para> /// This method must break the contents of the object. The part of content that fit in current object's /// bounds should remain in this object, the part that does not fit should be transferred to <b>breakTo</b> /// object. /// </para> /// </remarks> public virtual bool Break(BreakableComponent breakTo) { return(false); }