public override void OverRender(GUIRenderContext Context) { if (this._ScoreSample == null) { this._ScoreSample = Font.Default.CreateSample(this.Board.GetScore(0).ToString()); } Context.DrawText(Color.RGB(0.0, 0.0, 0.0), this._ScoreSample, new Point(10.0, 10.0)); }
/// <summary> /// Draws text to the specified region, overriding its layout parameters. /// </summary> public void DrawText(Color Color, TextSample Sample, Rectangle Region, TextAlign HorizontalAlign, TextAlign VerticalAlign) { double x = Region.Location.X; double y = Region.Location.Y; switch (HorizontalAlign) { case TextAlign.Center: x += Region.Size.X / 2.0 - Sample.Size.X / 2.0; break; case TextAlign.Right: x += Region.Size.X - Sample.Size.X; break; } switch (VerticalAlign) { case TextAlign.Center: y += Region.Size.Y / 2.0 - Sample.Size.Y / 2.0; break; case TextAlign.Bottom: y += Region.Size.Y - Sample.Size.Y; break; } this.DrawText(Color, Sample, new Point(x, y)); }
/// <summary> /// Draws text to the specified region using the layout parameters it was supplied with. /// </summary> public void DrawText(Color Color, TextSample Sample, Rectangle Region) { this.DrawText(Color, Sample, Region, Sample.HorizontalAlign, Sample.VerticalAlign); }
/// <summary> /// Draws text to the specified location. /// </summary> public void DrawText(Color Color, TextSample Sample, Point TopLeft) { Sample.Render(Color, TopLeft); }
private void _CreateSample() { Font font = this._Style.Font; string text = this._Text; this._Sample = font.CreateSample(text, this.Size, this._Style.HorizontalAlign, this._Style.VerticalAlign, this._Style.Wrap); }
protected override void OnResize(Point Size) { this._Sample = null; }
public _Item(PopupStyle Style, MenuItem Source, double Y) { this.Source = Source; this.Y = Y; TextMenuItem tmi = Source as TextMenuItem; if (tmi != null) { this.Sample = Style.Font.CreateSample(tmi.Text, null, TextAlign.Left, TextAlign.Center, TextWrap.Ellipsis); } CommandMenuItem cmi = Source as CommandMenuItem; if (cmi != null) { this.Size = new Point(this.Sample.Size.X, Style.StandardItemHeight); } CompoundMenuItem cpmi = Source as CompoundMenuItem; if (cpmi != null) { this.Size = new Point(this.Sample.Size.X + Style.CompoundArrowSize.X, Style.StandardItemHeight); } SeperatorMenuItem smi = Source as SeperatorMenuItem; if (smi != null) { this.Size = new Point(0.0, Style.SeperatorHeight + Style.SeperatorPadding * 2.0); } }
private void _MakeTextSample() { string text = this._Text; if(this._PasswordMask != null && this._PasswordMask.Length != 0) { text = ""; for(int i = 0; i < this._Text.Length; i++) text += this._PasswordMask; } this._TextSample = this._Style.Font.CreateSample(text); }
public override void Render(GUIRenderContext Context) { CheckboxStyle style = this._Style; Skin s = style.Skin; Surface surfbox = s.GetSurface(style.Box, style.BoxSize); Context.DrawSurface(surfbox); if(this.Checked) { Surface surftick = s.GetSurface(style.Tick, style.BoxSize); Context.DrawSurface(surftick); } Rectangle textrect = new Rectangle(style.BoxSize.X + style.Padding, 0, this.Size.X - style.BoxSize.X, this.Size.Y); if(this._Sample == null) this._Sample = style.TextFont.CreateSample(this._Text, textrect.Size, TextAlign.Left, TextAlign.Top, TextWrap.Wrap); Context.DrawText(style.TextColor, this._Sample, textrect); }
protected override void OnResize(Point Size) { if (this._Sample != null) { this._Sample.Dispose(); this._Sample = null; } }
public override void Render(GUIRenderContext Context) { Rectangle clirect = this.ClientRectangle; // Back Context.DrawSolid(this._Style.BackColor, clirect); // Client Context.PushTranslate(clirect.Location); this._Client.Render(Context); Context.Pop(); // Form Skin s = this._Style.Skin; Context.DrawSurface(s.GetSurface(this._Style.Form, this._Style.Form.Width / 2, this._Style.FormVerticalStretchLine, this.Size)); // Right of the title bar. Context.PushTranslate(this._RightTitleBarOffset); this._RightTitleBar.Render(Context); Context.Pop(); // Text if (this._Text != null && this._Text != "") { Rectangle textrect = new Rectangle( this._Style.TitleBarLeftRightMargin, this._Style.TitleBarTopMargin, this.Size.X - this._Style.TitleBarLeftRightMargin - this._RightTitleBar.Size.X - this._Style.TitleBarItemSeperation, this._Style.TitleBarSize - this._Style.TitleBarTopMargin - this._Style.TitleBarBottomMargin); if (this._TextSample == null) { this._TextSample = this._Style.TitleBarFont.CreateSample(this._Text, textrect.Size, TextAlign.Left, TextAlign.Center, TextWrap.Ellipsis); } Context.DrawText(this._Style.TitleBarTextColor, this._TextSample, textrect); } }
protected override void OnBoardChange(Board NewBoard) { if (this._Game.Player == NewBoard.PlayerToMove) { this._Moves = new List<KeyValuePair<Move, Board>>(NewBoard.Moves); } else { this._Moves = new List<KeyValuePair<Move, Board>>(); } this._Selection = null; if (this._ScoreSample != null) { this._ScoreSample.Dispose(); this._ScoreSample = null; } }