public void AllControls() { PunchcardFormat format = new PunchcardFormat(); format.boxesAcross = 6; format.boxesDown = 3; format.leftToRight = true; format.topToBottom = true; CheckRenderBitmap(TestUtil.GetTestFile("punchcards\\sample1.ppen"), CourseId(0), format); }
public void RegularCourse1() { PunchcardFormat format = new PunchcardFormat(); format.boxesAcross = 9; format.boxesDown = 3; format.leftToRight = false; format.topToBottom = false; CheckRenderBitmap(TestUtil.GetTestFile("punchcards\\sample1.ppen"), CourseId(2), format); }
public void ScoreCourse() { PunchcardFormat format = new PunchcardFormat(); format.boxesAcross = 8; format.boxesDown = 3; format.leftToRight = true; format.topToBottom = true; CheckRenderBitmap(TestUtil.GetTestFile("punchcards\\sample1.ppen"), CourseId(7), format); }
public void AlternateStart1() { PunchcardFormat format = new PunchcardFormat(); format.boxesAcross = 9; format.boxesDown = 3; format.leftToRight = false; format.topToBottom = false; CheckRenderBitmap(TestUtil.GetTestFile("punchcards\\sample2.ppen"), CourseId(2), format); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmap(string filename, Id <Course> id, PunchcardFormat format) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); Bitmap bmNew = RenderToBitmap(eventDB, courseView, format); TestUtil.CheckBitmapsBase(bmNew, GetBitmapFileName(eventDB, id, "")); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmap(string filename, Id<Course> id, PunchcardFormat format) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); Bitmap bmNew = RenderToBitmap(eventDB, courseView, format); TestUtil.CheckBitmapsBase(bmNew, GetBitmapFileName(eventDB, id, "")); }
// Render a description to a bitmap for testing purposes. Hardcoded 70 pixel box size. internal static Bitmap RenderToBitmap(EventDB eventDB, CourseView courseView, PunchcardFormat format) { PunchesRenderer punchesRenderer = new PunchesRenderer(eventDB); punchesRenderer.CourseView = courseView; punchesRenderer.PunchcardFormat = format; punchesRenderer.CellSize = 70; punchesRenderer.Margin = 4; SizeF size = punchesRenderer.Measure(); Bitmap bm = new Bitmap((int) size.Width, (int) size.Height); Graphics g = Graphics.FromImage(bm); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.Clear(Color.White); punchesRenderer.Draw(g, 0, 0, 0, punchesRenderer.Boxes.Height); g.Dispose(); return bm; }
// Render a description to a bitmap for testing purposes. Hardcoded 70 pixel box size. internal static Bitmap RenderToBitmap(EventDB eventDB, CourseView courseView, PunchcardFormat format) { PunchesRenderer punchesRenderer = new PunchesRenderer(eventDB); punchesRenderer.CourseView = courseView; punchesRenderer.PunchcardFormat = format; punchesRenderer.CellSize = 70; punchesRenderer.Margin = 4; SizeF size = punchesRenderer.Measure(); Bitmap bm = new Bitmap((int)size.Width, (int)size.Height); Graphics g = Graphics.FromImage(bm); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.Clear(Color.White); punchesRenderer.Draw(new GDIPlus_GraphicsTarget(g), 0, 0, 0, punchesRenderer.Boxes.Height); g.Dispose(); return(bm); }
public void ChangePunchcardFormat() { Setup("changeevent\\speciallegs3.coursescribe"); PunchcardFormat format = new PunchcardFormat(); format.boxesAcross = 6; format.boxesDown = 5; format.leftToRight = false; format.topToBottom = true; undomgr.BeginCommand(9111, "Change punch card layout"); ChangeEvent.ChangePunchcardFormat(eventDB, format); undomgr.EndCommand(9111); format.boxesAcross = 17; PunchcardFormat newFormat = eventDB.GetEvent().punchcardFormat; Assert.AreEqual(6, newFormat.boxesAcross); Assert.AreEqual(5, newFormat.boxesDown); Assert.IsFalse(newFormat.leftToRight); Assert.IsTrue(newFormat.topToBottom); }