public DQEGraphAnnotationUI(DQEGraphAnnotation a, Chart chart) { _underlyingAnnotationObject = a; Annotation = new LineAnnotation(); Annotation.IsSizeAlwaysRelative = false; Annotation.AxisX = chart.ChartAreas[0].AxisX; Annotation.AxisY = chart.ChartAreas[0].AxisY; Annotation.AnchorX = a.EndX; Annotation.AnchorY = a.EndY; Annotation.Height = a.StartY - a.EndY; Annotation.Width = a.StartX - a.EndX; Annotation.LineWidth = 2; Annotation.StartCap = LineAnchorCapStyle.Arrow; Annotation.EndCap = LineAnchorCapStyle.None; Annotation.AllowSelecting = true; Annotation.Tag = this; TextAnnotation = new TextAnnotation(); TextAnnotation.Text = a.Text; TextAnnotation.IsSizeAlwaysRelative = false; TextAnnotation.AxisX = chart.ChartAreas[0].AxisX; TextAnnotation.AxisY = chart.ChartAreas[0].AxisY; TextAnnotation.AnchorX = a.StartX; TextAnnotation.AnchorY = a.StartY; TextAnnotation.AllowSelecting = true; TextAnnotation.Tag = this; }
public void TestCreatingOne() { Catalogue c = new Catalogue(CatalogueRepository, "FrankyMicky"); try { var dqeRepo = new DQERepository(CatalogueRepository); Evaluation evaluation = new Evaluation(dqeRepo, c); var annotation = new DQEGraphAnnotation(dqeRepo, 1, 2, 3, 4, "Fishesfly", evaluation, DQEGraphType.TimePeriodicityGraph, "ALL"); Assert.AreEqual(annotation.StartX, 1); Assert.AreEqual(annotation.StartY, 2); Assert.AreEqual(annotation.EndX, 3); Assert.AreEqual(annotation.EndY, 4); Assert.AreEqual(annotation.AnnotationIsForGraph, DQEGraphType.TimePeriodicityGraph); //should be about 2 milliseconds ago Assert.IsTrue(annotation.CreationDate <= DateTime.Now.AddSeconds(3)); //certainly shouldnt be before yesterday! Assert.IsTrue(annotation.CreationDate > DateTime.Now.AddDays(-1)); //text should match Assert.AreEqual(annotation.Text, "Fishesfly"); annotation.Text = "flibble"; annotation.SaveToDatabase(); annotation.Text = ""; //new copy is flibble Assert.AreEqual("flibble", dqeRepo.GetObjectByID <DQEGraphAnnotation>(annotation.ID).Text); annotation.DeleteInDatabase(); } finally { c.DeleteInDatabase(); } }