public SizeF Measure(string fontTag, string text, float width, FontFormat format) { IGUIFont font = FontByTag(fontTag); if (font == null) { return(SizeF.Empty); } return(font.Measure(text, width, format)); }
public SizeF Measure(string fontTag, string text, int start = 0, int len = -1) { IGUIFont font = FontByTag(fontTag); if (font == null) { return(SizeF.Empty); } return(font.Measure(text, start, len)); }
public static SizeF DrawString(this IGUIContext ctx, string text, IGUIFont font, Brush brush, float x, float y, FontFormat format) { if (ctx == null) { return(SizeF.Empty); } SizeF contentSize = font.Measure(text); switch (format.HAlign) { case Alignment.Near: break; case Alignment.Center: x -= contentSize.Width / 2f; break; case Alignment.Far: x -= contentSize.Width; break; } // ToDo: Was soll das hier noch ? switch (format.VAlign) { case Alignment.Near: y -= contentSize.Height / 2f; break; case Alignment.Center: y += contentSize.Height / 2f; break; case Alignment.Far: case Alignment.Baseline: y += contentSize.Height / 2; break; } SizeF retVal; font.Begin(ctx); Color c = Color.Empty; if (brush != null) { c = brush.Color; } retVal = font.Print(text, new RectangleF(x, y, contentSize.Width, contentSize.Height), format, c); font.End(); return(retVal); }
public MonthCalendar(string name, IGUIFont dayFont, IGUIFont titleFont) : base(name, Docking.Fill, new MonthCalendarStyle()) { m_Weekdays = new string[7]; for (int i = 0; i < 7; i++) { m_Weekdays [i] = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName((DayOfWeek)i); } DayFont = dayFont; TitleFont = titleFont; this.SetIconFontByTag(CommonFontTags.SmallIcons); Format = new FontFormat(Alignment.Center, Alignment.Center, FontFormatFlags.Elipsis); this.Padding = new Padding(8); Timer = new TaskTimer(150, TimerAction, 500); MinCircleRadius = DayFont.Measure("0").Height * 0.75f; MaxCircleRadius = MinCircleRadius * 1.5f; ShowDate(); }
public override SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize) { if (CachedPreferredSize == SizeF.Empty) { float w = 0; float h = 0; if (IconFont != null && Icon != 0) { Size sz = IconFont.Measure(Icon.ToString()).ToSize(); h = sz.Height; w += sz.Width * 1.5f; } if (Font != null && !String.IsNullOrEmpty(Text)) { if (Format.HasFlag(FontFormatFlags.WrapText) && proposedSize.Width - w > 0) { SizeF sz = Font.Measure(Text, proposedSize.Width - w - Padding.Width, Format).ToSize(); h = Math.Max(h, sz.Height); w += sz.Width + 4; } else { SizeF sz = Font.Measure(Text).ToSize(); h = Math.Max(h, sz.Height); w += sz.Width; } } CachedPreferredSize = new SizeF(w + Padding.Width, h + Padding.Height); } return(CachedPreferredSize); }
public override void DrawDayHeader(IGUIContext gfx, System.Drawing.RectangleF rect, DateTime date) { if (date.Date.Equals(DateTime.Now.Date)) { gfx.DrawHighlightButton(rect); } else { gfx.DrawGrayButton(rect); } if (rect.Width < 2 || date == DateTime.MinValue) { return; } IGUIFont fntDay = BaseFont; string strDate; int StringWith = 0; try { strDate = date.ToString("D"); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 5) { strDate = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek) + ", " + date.ToString("d"); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 5) { strDate = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek) + ", " + date.ToString("d"); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 5) { strDate = date.ToString("d"); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 5) { strDate = date.ToString("m"); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 3) { strDate = date.Day.ToString() + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(date.Month); StringWith = (int)fntDay.Measure(strDate).Width; if (StringWith > rect.Width - 3) { strDate = date.Day.ToString(); } } } } } } } catch (Exception) { strDate = "?"; } //gfx.DrawString (strDate, BaseFont, SummerGUI.Theme.Brushes.Base02, rect, m_DayHeaderFormat); gfx.DrawString(strDate, HeaderFont, SummerGUI.Theme.Brushes.Base01, rect, m_DayHeaderFormat); }
public static SizeF MeasureString(this IGUIContext ctx, string text, IGUIFont font, RectangleF rect, FontFormat format) { return(font.Measure(text, rect.Width, format)); }