protected override void OnPaint(PaintEventArgs e) { this.context = new GlyphContext(); this.context.SetFont(new Font("Arial", 20f)); Glyph page = factory.CreatePage(); Glyph column1 = factory.CreateColumn(); column1.X = 10; column1.Y = 10; column1.Width = 380; column1.Height = 380; Glyph column2 = factory.CreateColumn(); column2.X = 410; column2.Y = 10; column2.Width = 380; column2.Height = 380; Glyph row1 = factory.CreateRow(); Glyph row2 = factory.CreateRow(); Glyph row3 = factory.CreateRow(); page.Insert(column1, null); page.Insert(column2, null); column1.Insert(row1, null); column1.Insert(row2, null); column2.Insert(row3, null); char[] charArray = "Abc".ToCharArray(); foreach (var item in charArray) { row1.Insert(factory.CreateCharacter(item), null); } charArray = "APPARENT".ToCharArray(); foreach (var item in charArray) { row2.Insert(factory.CreateCharacter(item), null); } charArray = "xyz".ToCharArray(); foreach (var item in charArray) { row3.Insert(factory.CreateCharacter(item), null); } page.Draw(this, null); }
public override void Draw(Form window, GlyphContext context) { int currentX = this.X; int currentY = this.Y; int maxSize = 0; foreach (var character in this.glyphs) { character.X = currentX; character.Y = currentY; currentX += character.Width; if (maxSize < character.Height) { this.Height = maxSize = character.Height; } this.Height = character.Height; character.Draw(window, context); } this.graphics = window.CreateGraphics(); this.graphics.DrawRectangle(new Pen(this.Color, 1), new Rectangle(new Point(this.X, this.Y), new Size(this.Width, this.Height))); }
public override void Draw(Form window, GlyphContext context) { this.graphics = window.CreateGraphics(); this.graphics.DrawRectangle(new Pen(this.color, 5), new Rectangle(point, size)); foreach (var glyph in this.glyphs) { glyph.Draw(window, context); } }
public override void Insert(Glyph glyph, GlyphContext context) { if (glyph is Row) { this.glyphs.Add(glyph); } else { throw new ArgumentException("В столбец допустимо помещать только строки - Row"); } }
public override void Insert(Glyph glyph, GlyphContext context) { if (glyph is Column) { if (this.glyphs.Count < 2) { this.glyphs.Add(glyph); } } else { throw new ArgumentException("В страницу допустимо помещать только столбцы - Column "); } }
public override void Insert(Glyph glyph, GlyphContext context) { if (glyph is Character) { if (this.actualWidthRow + glyph.Width > this.Width) { throw new ArgumentOutOfRangeException("Помещаемый символ не помещается в строку."); } this.actualWidthRow += glyph.Width; this.glyphs.Add(glyph); } else { throw new ArgumentException("В строку допустимо помещать только символы - Character"); } }
public override void Draw(Form window, GlyphContext context) { int currentX = this.X + 5; int currentY = this.Y + 5; foreach (var row in this.glyphs) { row.X = currentX; row.Y = currentY; currentY += row.Height; row.Width = this.Width - 10; row.Draw(window, context); } this.graphics = window.CreateGraphics(); this.graphics.DrawRectangle(new Pen(this.Color, 2), new Rectangle(new Point(this.X, this.Y), new Size(this.Width, this.Height))); }
public abstract void Next(GlyphContext context);
public abstract Font GetFont(GlyphContext context);
public abstract void First(GlyphContext context);
public abstract void Draw(Form window, GlyphContext context);
public abstract void SetFont(Font font, GlyphContext context);
public override bool IsDone(GlyphContext context) { throw new InvalidOperationException(); }
public override void Remove(GlyphContext context) { throw new NotImplementedException(); }
public override bool IsDone(GlyphContext context) { throw new NotImplementedException(); }
public override Glyph Current(GlyphContext context) { throw new NotImplementedException(); }
public abstract void Insert(Glyph glyph, GlyphContext context);
public override void SetFont(Font font, GlyphContext context) { this.context = context; }
public override void Remove(GlyphContext context) { throw new InvalidOperationException(); }
public override void Insert(Glyph glyph, GlyphContext context) { throw new InvalidOperationException(); }
public override Glyph Current(GlyphContext context) { throw new InvalidOperationException(); }
public abstract bool IsDone(GlyphContext context);
public override void Draw(Form window, GlyphContext context) { this.graphics = window.CreateGraphics(); this.graphics.DrawString(character, font, brush, this.X, this.Y); }
public abstract Glyph Current(GlyphContext context);
public override Font GetFont(GlyphContext context) { return(context.GetFont()); }
public abstract void Remove(GlyphContext context);
public override void SetFont(Font font, GlyphContext context) { throw new NotImplementedException(); }