/** * Generates a drawing engine which will draw the given pedigree model. */ public static DrawingEngine generateDrawingEngine(PedigreeModel model) { DrawingEngine drawingEngine = new DrawingEngine(); drawingEngine.addDrawingStep(delegate(Graphics g) { foreach (PedigreeCouple couple in model.couples) { rect.X = (int)couple.point.x; rect.Y = (int)couple.point.y; g.DrawEllipse(pen, rect); } }); return drawingEngine; }
private void TestForm_Load(object sender, EventArgs e) { List<SimpleIndividual> individuals = new List<SimpleIndividual>(); int NIL = SimpleIndividual.NULL_ID; int MALE = SimpleIndividual.GENDER_MALE; int FEMALE = SimpleIndividual.GENDER_FEMALE; individuals.Add(new SimpleIndividual(0, NIL, NIL, MALE)); individuals.Add(new SimpleIndividual(1, NIL, NIL, FEMALE)); individuals.Add(new SimpleIndividual(2, 0, 1, FEMALE)); //create the pedigree model from the input data PedigreeModel model = new PedigreeModel(individuals); //create the layout engine, which is responsible for //updating the state of the model each frame LayoutEngine layoutEngine = PedigreeLayout.generateLayoutEngine(model); //create the drawing engine, which is responsible for //visualizing the state of the model each frame DrawingEngine drawingEngine = PedigreeDrawing.generateDrawingEngine(model); //create the user control which will do the drawing DrawingEngineControl control = new DrawingEngineControl(drawingEngine); //wire the necessary mouse events from the control to the model control.MouseDown += model.MouseDown; control.MouseMove += model.MouseMove; control.MouseUp += model.MouseUp; //add the control to this form control.Location = new System.Drawing.Point(0, 0); int w = ClientSize.Width, h = ClientSize.Height; control.Size = new System.Drawing.Size(w, h); this.Controls.Add(control); //spawn a new thread which periodically increments the //layout and redraws the pedigree Animation.SpawnAnimationThread(layoutEngine, this, interFrameSleepTimeMillis); }
/** * Generates a layout engine which will act on the given pedigree model. */ public static LayoutEngine generateLayoutEngine(PedigreeModel model) { LayoutEngine layoutEngine = new LayoutEngine(); return layoutEngine; }