public void RasterizeTest() { IRasterControlView View = MockRepository.GenerateStub <IRasterControlView>(); View.Resolution = 100; View.RasterWidth = 1; View.IsCartesian = true; View.BB = new Rect(0.5, 0.5, 10, 10); View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix(); RasterControlModel target = new RasterControlModel(View); Point p = new Point(3, 3); // TODO: Initialize to an appropriate value Point expected = new Point(3, 3); // TODO: Initialize to an appropriate value Point actual; actual = target.Rasterize(p); Assert.AreEqual(expected, actual); p = new Point(3.2, 3.7); expected = new Point(3, 4); actual = target.Rasterize(p); Assert.AreEqual(expected, actual); p = new Point(3.2, 3.5); expected = new Point(3, 4); actual = target.Rasterize(p); Assert.AreEqual(expected, actual); }
public RasterControl() { InitializeComponent(); if (DesignMode) { return; } disablerPanel = new Panel() { Dock = DockStyle.Fill, BackColor = Color.Transparent, Visible = false, Cursor = Cursors.No }; toolTip1.SetToolTip(disablerPanel, "Overlay out of sync. WYSIWYG editing is disabled"); //toolTip1.SetToolTip(this, "The WYSIWYG area"); //toolTip1.Popup += new PopupEventHandler(toolTip1_Popup); //toolTip1.ReshowDelay = 50; //toolTip1.InitialDelay = 100; //toolTip1.ShowAlways = true; toolTip1.Active = true; this.MouseHover += new EventHandler(RasterControl_MouseHover); this.Controls.Add(disablerPanel); CreateContextMenu(); //this.CanFocus = true; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable, true); TheRasterModel = new RasterControlModel(this); IPdfToBmp <Bitmap> Pdf2Bmp; if (CompilerSettings.Instance.UseExternalRenderer) { Pdf2Bmp = new PdfToBmpExtWinForms(); } else { Pdf2Bmp = new PdfToBmp(); } TheDisplayModel = new TikzDisplayModel <Bitmap>(this, Pdf2Bmp); TheOverlayModel = new PdfOverlayModel(this, this); TheOverlayModel.DisplayTree.DisplayTreeChanged += new EventHandler <TikzDisplayTree.DisplayTreeChangedEventArgs>(DisplayTree_DisplayTreeChanged); MarkObject_Timer.Interval = 500; MarkObject_Timer.Tick += new EventHandler(MarkObject_Timer_Tick); // listen to Bitmap changes MyBindings.Add(BindingFactory.CreateBinding(TheDisplayModel, "Bmp", (o) => this.Invalidate(), null)); }
public RasterControl(EventBox parent) { ParentBox = parent; disablerPanel = new DrawingArea();//{ Opacit = Color.Transparent, Visible = false, Curso = Cursors.No }; disablerPanel.TooltipText = "Overlay out of sync. WYSIWYG editing is disabled"; //toolTip1.SetToolTip(disablerPanel, "Overlay out of sync. WYSIWYG editing is disabled"); // this.PackStart(disablerPanel, true, true,0); //toolTip1.SetToolTip(this, "The WYSIWYG area"); //toolTip1.Popup += new PopupEventHandler(toolTip1_Popup); //toolTip1.ReshowDelay = 50; //toolTip1.InitialDelay = 100; //toolTip1.ShowAlways = true; toolTip1.Active = true; //todo this.MouseHover += new EventHandler(RasterControl_MouseHover); CreateContextMenu(); //this.CanFocus = true; //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable, true); DoubleBuffered = true; TheRasterModel = new RasterControlModel(this); TheDisplayModel = new TikzDisplayModel <Cairo.ImageSurface>(this, new PdfToBmpExtGTK()); TheOverlayModel = new PdfOverlayModel(this, this); MarkObject_Timer.Interval = 500; MarkObject_Timer.Tick += new EventHandler(MarkObject_Timer_Tick); // listen to Bitmap changes MyBindings.Add(BindingFactory.CreateBinding(TheDisplayModel, "Bmp", (o) => this.Invalidate(), null)); parent.ButtonPressEvent += OnButtonPress; parent.ButtonReleaseEvent += OnButtonRelease; parent.MotionNotifyEvent += OnMotionNotify; parent.KeyPressEvent += OnKeyPress; parent.KeyReleaseEvent += OnKeyRelease; }
public void RasterizePixelToTikzTest() { IRasterControlView View = MockRepository.GenerateStub <IRasterControlView>(); View.Resolution = 100; View.RasterWidth = 1; View.IsCartesian = true; View.BB = new Rect(0, 0, 10, 10); View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix(); RasterControlModel target = new RasterControlModel(View); Point p = new Point(30, 70); Point expected = new Point(0, 1); Point actual; actual = target.RasterizePixelToTikz(p); Assert.AreEqual(expected, actual); }
public void DrawRasterTest() { IRasterControlView View = MockRepository.GenerateStub <IRasterControlView>(); View.Resolution = 100; View.RasterWidth = 1; View.IsCartesian = true; View.BB = new Rect(0, 0, 10, 10); View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix(); RasterControlModel target = new RasterControlModel(View); List <Point> lstpts = new List <Point>(); List <double> lstrads = new List <double>(); Action <Point, Point> LineDrawMethod = (p1, p2) => lstpts.Add(p1); Action <double, double> EllipseDrawMethod = (r1, r2) => lstrads.Add(r1); target.DrawRaster(LineDrawMethod, EllipseDrawMethod); Assert.IsTrue(lstpts.TrueForAll(p => p.X == Math.Round(p.X) && p.Y == Math.Round(p.Y))); Assert.AreEqual(0, lstrads.Count); }