/// <summary> /// Create a new Page /// </summary> /// <param Name="x">The x coordinate of the top-left corner of the page</param> /// <param Name="y">The y coordinate of the top-left corner of the page</param> /// <param Name="c">The character the page is initialised with</param> /// <param Name="document">The document the page is attached to</param> /// <param Name="pr">The previous page in the document</param> /// <param Name="nx">The next page in the document</param> public Page(float x, float y, char c, Document document, Page pr, Page nx) : base(c.ToString(), document.Window) { Document = document; Prev = pr; Next = nx; EscapeKeys = new ReadOnlyDictionary<Keys, ShowInterfaceHandler>( new Dictionary<Keys, ShowInterfaceHandler>() { {Keys.F1, Window.CommandHandler}, {Keys.F2, Window.FindHandler}, {Keys.F3, Window.FindHandler} }); //Set the size of the page ConstrainHeightToTextHeight = false; ConstrainWidthToTextWidth = false; Bounds = new RectangleF(x, y, PageSize.A4.Width, PageSize.A4.Height); DrawBorder(); //Add event listeners AddInputEventListener(Window.CommandHandler); AddInputEventListener(Window.FindHandler); ConfirmSelection += Window.ConfirmSelection; Reflow += OnReflow; Model.KeyDown += Model_KeyDown; }
/// <summary> /// When the user clicks, record this as the page with focus /// </summary> /// <param Name="e"></param> public override void OnMouseDown(PInputEventArgs e) { LastPage = this; base.OnMouseDown(e); }
/// <summary> /// When the layout updates, move any overflow to the next page and ensure the border still exists /// </summary> protected void OnReflow() { //Ensure the border still exists if (IndexOfChild(Border) < 0) { AddChild(Border); Border.MoveToBack(); } //Move any overflow to the next page if (Overflow != null) { //Create a new page if required if (Next == null) { Next = new Page((int)X, (int)(Y + Height + 10), ' ', Document, this, null); Document.AddChild(Next); } //Move the overflow to the next page Next.AddRtfAt(Overflow.Rtf, 0); ClearOverflow(); } }
/// <summary> /// When keyboard focus is assigned to this page, record this as the page with focus /// </summary> /// <param Name="e"></param> public override void OnGotFocus(PInputEventArgs e) { LastPage = this; base.OnGotFocus(e); }