public virtual void DrawInRect(CDVContext context) { int x, y; GetAbsoluteLocation(out x, out y); border.X = x - ContentRect.X + ParaStyle.Margin.Left; border.Y = y - ContentRect.Y + ParaStyle.Margin.Top; border.Width = Bounds.Width - ParaStyle.Margin.Left - ParaStyle.Margin.Right; border.Height = Bounds.Height - ParaStyle.Margin.Top - ParaStyle.Margin.Bottom; if (!ParaStyle.BackgroundColor.Equals(CDVColor.Transparent)) { context.g.FillRectangle(CDVContext.GetBrush(ParaStyle.BackgroundColor), border); } if (ParaStyle.BorderWidth.GetMax() > 0) { context.g.DrawLine(CDVContext.GetPen(ParaStyle.BorderWidth.Top, ParaStyle.BorderColor), border.Left, border.Top, border.Right, border.Top); context.g.DrawLine(CDVContext.GetPen(ParaStyle.BorderWidth.Bottom, ParaStyle.BorderColor), border.Left, border.Bottom, border.Right, border.Bottom); context.g.DrawLine(CDVContext.GetPen(ParaStyle.BorderWidth.Left, ParaStyle.BorderColor), border.Left, border.Top, border.Left, border.Bottom); context.g.DrawLine(CDVContext.GetPen(ParaStyle.BorderWidth.Right, ParaStyle.BorderColor), border.Right, border.Top, border.Right, border.Bottom); } //context.g.DrawRectangle(Pens.Blue, border); }
public override int GetMinimumWidth(CDVContext context) { Font f = CDVContext.GetFont(TextStyle.Font, TextStyle.FontSize, TextStyle.Bold, TextStyle.Italic, TextStyle.Underline); SizeF sf = context.g.MeasureString(Text, f); return(base.GetMinimumWidth(context)); }
public virtual void MeasureRect(CDVContext context, int maxWidth) { if (!Visible) { Size = Size.Empty; } }
public override int GetMinimumWidth(CDVContext context) { int minWidth = 0; foreach (CDVAtom atom in Words) { minWidth = Math.Max(minWidth, atom.GetMinimumWidth(context)); } return(minWidth); }
public override void DrawInRect(CDVContext context) { if (!Visible) { return; } base.DrawInRect(context); foreach (CDVAtom atom in Words) { atom.DrawInRect(context); } }
public void Prepare(CDVContext ctx, int clientWidth) { if (!measured) { ctx.rulersReflow = false; Item.MeasureRect(ctx, clientWidth); if (ctx.rulersChanged) { ctx.rulersReflow = true; Item.MeasureRect(ctx, clientWidth); } Item.ApplySpanWidths(clientWidth); Item.ApplyContentAlignment(); measured = true; } }
public override void DrawInRect(CDVContext context) { if (!Visible) { return; } base.DrawInRect(context); int x, y; GetAbsoluteLocation(out x, out y); Font f = CDVContext.GetFont(TextStyle.Font, TextStyle.FontSize, TextStyle.Bold, TextStyle.Italic, TextStyle.Underline); context.g.DrawString(Text, f, CDVContext.GetBrush(TextStyle.Color), x, y); }
public override void MeasureRect(CDVContext context, int maxWidth) { int bx = p_para_style == null ? 0 : p_para_style.Margin.Left + p_para_style.Padding.Left; int by = p_para_style == null ? 0 : p_para_style.Margin.Top + p_para_style.Padding.Top; int bw = p_para_style == null ? 0 : p_para_style.Margin.Right + p_para_style.Padding.Right; int bh = p_para_style == null ? 0 : p_para_style.Margin.Bottom + p_para_style.Padding.Bottom; SizeF sf = SizeF.Empty; if (context.rulersReflow) { sf = new SizeF(ContentRect.Width - 1, ContentRect.Height - 1); } else { Font f = CDVContext.GetFont(TextStyle.Font, TextStyle.FontSize, TextStyle.Bold, TextStyle.Italic, TextStyle.Underline); sf = context.g.MeasureString(Text, f); } Bounds = new Rectangle(0, 0, (int)sf.Width + 1 + bx + bw, (int)sf.Height + 1 + by + bh); ContentRect = new Rectangle(bx, by, (int)sf.Width + 1, (int)sf.Height + 1); base.MeasureRect(context, maxWidth); }
public virtual int GetMinimumWidth(CDVContext context) { return(10); }
public override void MeasureRect(CDVContext context, int maxWidth) { Location = new Point(0, 0); Size = new Size(0, 4); int bx = p_para_style == null ? 0 : p_para_style.Margin.Left + p_para_style.Padding.Left; int by = p_para_style == null ? 0 : p_para_style.Margin.Top + p_para_style.Padding.Top; int bw = p_para_style == null ? 0 : p_para_style.Margin.Right + p_para_style.Padding.Right; int bh = p_para_style == null ? 0 : p_para_style.Margin.Bottom + p_para_style.Padding.Bottom; int x = 0; int y = 0; int maxLineWidth = 0; CDVLine line = new CDVLine(); if (Orientation == CDVOrientation.Vertical) { foreach (CDVAtom atom in Words) { atom.MeasureRect(context, maxWidth); atom.Location = new Point(x, y); y += atom.Height; maxLineWidth = Math.Max(maxLineWidth, atom.Width); } ContentRect = new Rectangle(bx, by, maxLineWidth, y); Size = new Size(ContentRect.Width + bx + bw, ContentRect.Height + by + bh); } else { foreach (CDVAtom atom in Words) { if (atom is CDVRuler) { CDVRuler ruler = (CDVRuler)atom; if (ruler.Value - ruler.Width / 2 > x) { x = ruler.Value + ruler.Width / 2; } else { context.rulersChanged = true; ruler.Value = Math.Max(ruler.Value, x + ruler.Width / 2); x += ruler.Width; } } else { atom.MeasureRect(context, maxWidth); if (x + atom.Bounds.Width + bx + bw > maxWidth && line.Count > 0) { x = 0; y += line.MaxHeight; line.ApplyAlignment(maxWidth - bx - bw, ParaStyle.Align); maxLineWidth = Math.Max(maxLineWidth, line.Right); Lines.Add(line); line = new CDVLine(); atom.Location = new Point(x, y); } else { atom.Location = new Point(x, y); x += atom.Bounds.Width; } } line.Add(atom); } maxLineWidth = Math.Max(maxLineWidth, line.Right); line.ApplyAlignment(maxWidth - bx - bw, ParaStyle.Align); Lines.Add(line); ContentRect = new Rectangle(bx, by, maxLineWidth, y + line.MaxHeight); Size = new Size(ContentRect.Width + bx + bw, ContentRect.Height + by + bh); } base.MeasureRect(context, maxWidth); }
/// <summary> /// Assumption is that at least MainAtom is correctly placed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CalendarDataView_Paint(object sender, PaintEventArgs e) { CDVDocumentCell firstDrawn = null; if (MainAtom == null) { e.Graphics.DrawString("Please wait a moment...", SystemFonts.MenuFont, Brushes.Black, BoundsFloat, CDVContext.StringFormatCenterCenter); return; } CDVContext ctx = new CDVContext(); ctx.g = e.Graphics; ctx.ScreenRect = this.ClientRectangle; CDVDocumentCell last = MainAtom; Rectangle clientArea = this.ClientRectangle; // drawing main atom if (MainAtom.RefreshLayout) { DataSource.SyncRefreshLayout(this, MainAtom); } MainAtom.Prepare(ctx, 5000); MainAtom.Item.DrawInRect(ctx); if (MainAtom.Item.Bounds.Bottom > ctx.ScreenRect.Top && MainAtom.Item.Bounds.Top < ctx.ScreenRect.Bottom) { firstDrawn = MainAtom; } //Debugger.Log(0, "", "Bottom: " + last.Item.Bounds.Bottom + ", Height: " + Height + "\n"); // drawing after while (Document.ContainsKey(last.NextKey) && last.Item.Bounds.Bottom < Height) { // drawing next atom CDVDocumentCell nc = Document.GetItemForKey(last.NextKey); if (nc.RefreshLayout) { DataSource.SyncRefreshLayout(this, nc); } nc.Prepare(ctx, 5000); nc.MoveAfter(last); nc.Item.DrawInRect(ctx); if (nc.Item.Bounds.Bottom > ctx.ScreenRect.Top && nc.Item.Bounds.Top < ctx.ScreenRect.Bottom && firstDrawn == null) { firstDrawn = nc; } last = nc; } if (!Document.ContainsKey(last.NextKey)) { // here place order to datasource for nextkey RequestAsyncKey(last.NextKey); } last = MainAtom; while (Document.ContainsKey(last.PrevKey) && last.Item.Bounds.Top > 0) { CDVDocumentCell nc = Document.GetItemForKey(last.PrevKey); if (nc.RefreshLayout) { DataSource.SyncRefreshLayout(this, nc); } nc.Prepare(ctx, 5000); nc.MoveBefore(last); nc.Item.DrawInRect(ctx); if (nc.Item.Bounds.Bottom > ctx.ScreenRect.Top && nc.Item.Bounds.Top < ctx.ScreenRect.Bottom && firstDrawn == null) { firstDrawn = nc; } last = nc; } if (!Document.ContainsKey(last.PrevKey)) { // here place order to datasource for nextkey RequestAsyncKey(last.PrevKey); } // setting MainAtom to document part, that is really drawn on the screen if (firstDrawn != MainAtom) { //Debugger.Log(0, "", "MainAtom changed\n"); MainAtom = firstDrawn; } }
public override void DrawInRect(CDVContext context) { }
public override void MeasureRect(CDVContext context, int maxWidth) { Bounds = new Rectangle(0, 0, Width, 30); }
public override int GetMinimumWidth(CDVContext context) { return Width; }