Ejemplo n.º 1
0
    /// <summary>
    /// Constructs the sprite drawing area, along with the various
    /// rules needed.
    /// </summary>
    public Viewer()
    {
        // Create the drop-down list
        HBox box = new HBox();
        fps = new SpinButton(1, 100, 1);
        fps.Value = DesiredFps;
        fps.Changed += OnFpsChanged;
        showUpdate = new CheckButton();
        box.PackStart(new Label("FPS"), false, false, 0);
        box.PackStart(fps, false, false, 2);
        box.PackStart(new Label("Show Update"), false, false, 5);
        box.PackStart(showUpdate, false, false, 2);
        box.PackStart(new Label(), true, true, 0);
        PackStart(box, false, false, 2);

        // Create the drawing area and pack it
        area = new DrawingArea();
        area.Realized += OnRealized;
        area.ExposeEvent += OnExposed;
        area.ConfigureEvent += OnConfigure;
        PackStart(area, true, true, 2);

        // Create the viewport
        Sprites = new SpriteList();
        viewport = new SpriteViewport(Sprites);

        // Start up a little animation loop
        Timeout.Add(1000 / DesiredFps, OnTick);
    }
Ejemplo n.º 2
0
    // Constructor
    public Gui()
    {
        Application.Init();

        ioh = new IoHandler();
        win = new Window("Drawing lines");
        darea = new  DrawingArea();
        painter = new DrawShape(DrawLine);
        listenOnMouse = false; // Við hlustum ekki á mús við núllstöðu.

        // Aukum viðburðasett teikniborðs með ,möskum'.
        darea.AddEvents(
                (int)Gdk.EventMask.PointerMotionMask
                | (int)Gdk.EventMask.ButtonPressMask
                | (int)Gdk.EventMask.ButtonReleaseMask);

        // Úthlutum virkni á viðburði.
        win.Hidden += delegate {Application.Quit();};
        win.KeyPressEvent += onKeyboardPressed;
        darea.ExposeEvent += onDrawingAreaExposed;
        darea.ButtonPressEvent += onMouseClicked;
        darea.ButtonReleaseEvent += onMouseReleased;
        darea.MotionNotifyEvent += onMouseMotion;

        // Grunnstillum stærð glugga.
        win.SetDefaultSize(500,500);

        // Lokasamantekt til að virkja glugga.
        win.Add(darea);
        win.ShowAll();
        Application.Run();
    }
Ejemplo n.º 3
0
	static void Main ()
	{
		Application.Init ();
		Gtk.Window w = new Gtk.Window ("System.Drawing and Gtk#");

		// Custom widget sample
		a = new PrettyGraphic ();

		// Event-based drawing
		b = new DrawingArea ();
		b.ExposeEvent += new ExposeEventHandler (ExposeHandler);
		b.SizeAllocated += new SizeAllocatedHandler (SizeAllocatedHandler);

		Button c = new Button ("Quit");
		c.Clicked += new EventHandler (quit);

		MovingText m = new MovingText ();
		
		Box box = new HBox (true, 0);
		box.Add (a);
		box.Add (b);
		box.Add (m);
		box.Add (c);
		w.Add (box);
		
		w.ShowAll ();
		Application.Run ();
	}
Ejemplo n.º 4
0
    public static void Do(List<JumpsProfileIndex> l_jpi, DrawingArea area)
    {
        //1 create context
        Cairo.Context g = Gdk.CairoHelper.Create (area.GdkWindow);

        //2 clear DrawingArea (white)
        g.SetSourceRGB(1,1,1);
        g.Paint();

        //3 calculate sum
        double sum = 0;
        foreach(JumpsProfileIndex jpi in l_jpi)
            sum += jpi.Result;

        //4 prepare font
        g.SelectFontFace("Helvetica", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        int textHeight = 12;
        g.SetFontSize(textHeight);

        //5 plot arcs
        if(sum > 0 ) {
            double acc = 0; //accumulated
            foreach(JumpsProfileIndex jpi in l_jpi) {
                double percent = 2 * jpi.Result / sum; //*2 to be in range 0*pi - 2*pi
                plotArc(200, 200, 150, acc -.5, acc + percent -.5, g, jpi.Color); //-.5 to start at top of the pie
                acc += percent;
            }
        }

        //6 draw legend at right
        int y = 50;
        //R seq(from=50,to=(350-24),length.out=5)
        //[1] 50 119 188 257 326 #difference is 69
        foreach(JumpsProfileIndex jpi in l_jpi) {
            drawRoundedRectangle (400,  y, 40, 24, 6, g, jpi.Color);

            double percent = 0;
            if(sum > 0)
                percent = 100 * jpi.Result / sum;

            printText(460,  y, 24, textHeight, Util.TrimDecimals(percent, 1) + jpi.Text, g);
            y += 69;
        }

        //7 print errors (if any)
        g.SetSourceRGB(0.5, 0, 0);
        y = 70;
        foreach(JumpsProfileIndex jpi in l_jpi) {
            printText(460,  y, 24, textHeight, jpi.ErrorMessage, g);
            y += 69;
        }

        //8 dispose
        g.GetTarget().Dispose ();
        g.Dispose ();
    }
Ejemplo n.º 5
0
    // IO
    public Gui()
    {
        Application.Init();

        win = new Window("Drawing lines");
        darea = new  DrawingArea();

        win.Add(darea);

        win.ShowAll();

        Application.Run();
    }
Ejemplo n.º 6
0
    public MainWindow()
        : base(WindowType.Toplevel)
    {
        VBox vBox = new VBox ();

        _da = new DrawingArea ();
        _da.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0, 0, 0));
        _da.SetSizeRequest (400, 300);
        _da.DoubleBuffered = false;
        vBox.PackStart (_da, true, true, 0);

        _scale = new HScale (0, 1, 0.01);
        _scale.DrawValue = false;
        _scale.ValueChanged += ScaleValueChanged;
        vBox.PackStart (_scale, false, false, 0);

        HBox hBox = new HBox ();

        Button btnOpen = new Button ();
        btnOpen.Label = "Open";
        btnOpen.Clicked += ButtonOpenClicked;

        hBox.PackStart (btnOpen, false, false, 0);

        Button btnPlay = new Button ();
        btnPlay.Label = "Play";
        btnPlay.Clicked += ButtonPlayClicked;

        hBox.PackStart (btnPlay, false, false, 0);

        Button btnPause = new Button ();
        btnPause.Label = "Pause";
        btnPause.Clicked += ButtonPauseClicked;

        hBox.PackStart (btnPause, false, false, 0);

        _lbl = new Label ();
        _lbl.Text = "00:00 / 00:00";

        hBox.PackEnd (_lbl, false, false, 0);

        vBox.PackStart (hBox, false, false, 3);

        Add (vBox);

        WindowPosition = Gtk.WindowPosition.Center;
        DeleteEvent += OnDeleteEvent;

        GLib.Timeout.Add (1000, new GLib.TimeoutHandler (UpdatePos));
    }
Ejemplo n.º 7
0
    public SharpApp()
        : base("Simple drawing")
    {
        SetDefaultSize(230,150);
        SetPosition(WindowPosition.Center);
        DeleteEvent += delegate {Application.Quit();};

        DrawingArea darea = new DrawingArea();
        darea.ExposeEvent += OnExpose;

        Add(darea);

        ShowAll();
    }
Ejemplo n.º 8
0
        protected override void OnMouseUp(DrawingArea canvas, ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // If the user didn't move the mouse, they want to deselect
            int tolerance = 0;

            if (Math.Abs(reset_origin.X - args.Event.X) <= tolerance && Math.Abs(reset_origin.Y - args.Event.Y) <= tolerance)
            {
                // Mark as being done interactive drawing before invoking the deselect action.
                // This will allow AfterSelectionChanged() to clear the selection.
                is_drawing = false;

                if (hist != null)
                {
                    // Roll back any changes made to the selection, e.g. in OnMouseDown().
                    hist.Undo();

                    hist.Dispose();
                    hist = null;
                }

                PintaCore.Actions.Edit.Deselect.Activate();
            }
            else
            {
                ClearHandles(doc.ToolLayer);
                ReDraw(args.Event.State);
                if (doc.Selection != null)
                {
                    SelectionModeHandler.PerformSelectionMode(combine_mode, doc.Selection.SelectionPolygons);

                    doc.Selection.Origin = shape_origin;
                    doc.Selection.End    = shape_end;
                    PintaCore.Workspace.Invalidate();
                }
                if (hist != null)
                {
                    doc.History.PushNewItem(hist);
                    hist = null;
                }
            }

            is_drawing     = false;
            active_control = null;

            // Update the mouse cursor.
            UpdateCursor(point);
        }
Ejemplo n.º 9
0
    void OnExpose(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context cairoContext = Gdk.CairoHelper.Create(darea.GdkWindow);

        //cairoContext.Antialias = Antialias.None;

        int width, height;

        width  = Allocation.Width;
        height = Allocation.Height;

        cairoContext.Translate(width / 2, height / 2);

        Circle(cairoContext, specialThing.spacials.pos.X, specialThing.spacials.pos.Y, 10, 1, 0, 0);

        Circle(cairoContext, 0, 0, world.radius, 0, 0, 0);

        foreach (var dude in Dude.allTheDudes)
        {
            dude.update();
            Circle(cairoContext, dude.spacials.pos.X, dude.spacials.pos.Y, dude.spacials.radius, dude.red, dude.green, dude.blue);
            Arc(cairoContext,
                dude.spacials.pos.X,
                dude.spacials.pos.Y,
                dude.spacials.radius * 2,
                dude.spacials.angle - dude.eyeAngle - dude.focus / 2,
                dude.spacials.angle - dude.eyeAngle + dude.focus / 2,
                dude.leftEyeSense[0],
                dude.leftEyeSense[1],
                dude.leftEyeSense[2]);

//			Arc(cairoContext,
//				dude.spacials.pos.X,
//				dude.spacials.pos.Y,
//				dude.spacials.radius*2,
//				dude.spacials.angle + dude.eyeAngle - dude.focus/2,
//				dude.spacials.angle + dude.eyeAngle + dude.focus/2,
//				dude.rightEyeSense[0],
//				dude.rightEyeSense[1],
//				dude.rightEyeSense[2]);
        }

        #region cleanup
        ((IDisposable)cairoContext.Target).Dispose();
        ((IDisposable)cairoContext).Dispose();
        #endregion
    }
Ejemplo n.º 10
0
    public SharpApp() : base("Polgon")
    {
        OpenOFD();
        SetDefaultSize(830, 650);
        SetPosition(WindowPosition.Center);
        DeleteEvent += delegate { Gtk.Application.Quit(); };;

        DrawingArea darea = new DrawingArea();

        darea.ExposeEvent += OnExpose;

        Add(darea);

        ShowAll();
    }
Ejemplo n.º 11
0
        public DemoPixbuf() : base("Pixbufs")
        {
            Resizable = false;
            SetSizeRequest(backWidth, backHeight);

            frame = new Pixbuf(Colorspace.Rgb, false, 8, backWidth, backHeight);

            drawingArea        = new DrawingArea();
            drawingArea.Drawn += new DrawnHandler(DrawnCallback);

            Add(drawingArea);
            timeoutId = GLib.Timeout.Add(FrameDelay, new GLib.TimeoutHandler(timeout));

            ShowAll();
        }
Ejemplo n.º 12
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7);       // set the color
        shape.Arc(100, 90, 70, 10, 2 * Math.PI); // our circle segment

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 13
0
Archivo: arc.cs Proyecto: nlhepler/mono
	static void Main ()
	{		
		Application.Init ();
		Gtk.Window w = new Gtk.Window ("Mono.Cairo Circles demo");

		a = new CairoGraphic ();	
		
		Box box = new HBox (true, 0);
		box.Add (a);
		w.Add (box);
		w.Resize (500,500);		
		w.ShowAll ();		
		
		Application.Run ();
	}
        public DemoRotatedText() : base("Rotated text")
        {
            DrawingArea drawingArea = new DrawingArea();

            Gdk.Color white = new Gdk.Color(0xff, 0xff, 0xff);

            // This overrides the background color from the theme
            drawingArea.ModifyBg(StateType.Normal, white);
            drawingArea.ExposeEvent += new ExposeEventHandler(RotatedTextExposeEvent);

            this.Add(drawingArea);
            this.DeleteEvent += new DeleteEventHandler(OnWinDelete);
            this.SetDefaultSize(2 * RADIUS, 2 * RADIUS);
            this.ShowAll();
        }
Ejemplo n.º 15
0
        public void BackGroundColorChangeMenuBar()
        {
            try {
                da1              = new DrawingArea();
                da1.ExposeEvent += OnExposed1;

                Gdk.Color col = new Gdk.Color();
                Gdk.Color.Parse("#3b5998", ref col);

                ModifyBg(StateType.Normal, col);
                da1.ModifyBg(StateType.Normal, col);
            } catch (Exception ex) {
                Console.Write(ex.Message);
            }
        }
Ejemplo n.º 16
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7); // set the color
        shape.Rectangle(100, 50, 100, 50); // our rectangle, his size: 100*50

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 17
0
    public static void Numbers(object sender)
    {
        DrawingArea area = (DrawingArea)sender;

        Cairo.Context cc = Gdk.CairoHelper.Create(area.GdkWindow);

        cc.SetSourceRGB(0, 0, 0);
        cc.LineWidth = 1;
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.MoveTo(20, 100);
        cc.ShowText(DateTime.Now.ToString());
        cc.StrokePreserve();
        cc.Fill();
    }
Ejemplo n.º 18
0
        public void SetEditionMode(EditionMode nm)
        {
            if (nm == mode)
            {
                return;
            }

            mode = nm;
            if (mode != null)
            {
                mode.Refresh();
            }

            DrawingArea.Invalidate();
        }
Ejemplo n.º 19
0
        TimerApp()
        {
            win = new Window("Timer Example");
            win.SetDefaultSize(260, 110);

            da = new DrawingArea();

            // For DeleteEvent
            Observable.FromEventPattern <DeleteEventArgs>(win, "DeleteEvent")
            .Subscribe(delegate
            {
                Application.Quit();
            });

            // For Timer
            Observable.Interval(TimeSpan.FromSeconds(1))
            .Subscribe(_ =>
            {
                Gtk.Application.Invoke(delegate
                {
                    da.QueueDraw();
                });
            });

            // For DrawingArea event
            Observable.FromEventPattern <DrawnArgs>(da, "Drawn")
            .Subscribe(args =>
            {
                Cairo.Context cr = args.EventArgs.Cr;

                cr.SetSourceRGB(0.5, 0.5, 0.5);
                cr.Paint();

                cr.SetFontSize(48);
                cr.MoveTo(20, 68);
                string date = DateTime.Now.ToString("HH-mm-ss");
                cr.SetSourceRGB(0.2, 0.23, 0.9);
                cr.ShowText(date);
                cr.Fill();

                ((IDisposable)cr).Dispose();

                args.EventArgs.RetVal = true;
            });

            win.Add(da);
            win.ShowAll();
        }
Ejemplo n.º 20
0
        /// <summary>Initializes a new instance of the <see cref="DirectedGraphView" /> class.</summary>
        public DirectedGraphView(ViewBase owner = null) : base(owner)
        {
            DrawingArea drawingArea = new DrawingArea();

            drawingArea.AddEvents(
            (int)Gdk.EventMask.PointerMotionMask
            | (int)Gdk.EventMask.ButtonPressMask
            | (int)Gdk.EventMask.ButtonReleaseMask);

            drawingArea.ExposeEvent += OnDrawingAreaExpose;
            drawingArea.ButtonPressEvent += OnMouseButtonPress;
            drawingArea.ButtonReleaseEvent += OnMouseButtonRelease; ;
            drawingArea.MotionNotifyEvent += OnMouseMove; ;
            _mainWidget = drawingArea;
            drawingArea.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255));
        }
Ejemplo n.º 21
0
    static void Main()
    {
        Gtk.Application.Init();
        Gtk.Window w = new Gtk.Window("RoadMap gridlines");

        a = new CairoGraphic();

        Box box = new HBox(true, 0);

        box.Add(a);
        w.Add(box);
        w.Resize(500, 500);
        w.ShowAll();

        Gtk.Application.Run();
    }
Ejemplo n.º 22
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7);          // set the color
        shape.MoveTo(25, 130);
        shape.CurveTo(100, 235, 165, 25, 255, 130); //our curve line

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 23
0
    static void Main()
    {
        Application.Init();
        Gtk.Window w = new Gtk.Window("Mono.Cairo Circles demo");

        a = new CairoGraphic();

        Box box = new HBox(true, 0);

        box.Add(a);
        w.Add(box);
        w.Resize(500, 500);
        w.ShowAll();

        Application.Run();
    }
Ejemplo n.º 24
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7); // set the color
        shape.LineTo(100, 50);             //first point
        shape.LineTo(300, 90);             // second point

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 25
0
        void MouseDrag(object sender, MouseEventArgs e)
        {
            Int32 LimitX = (int)(ScaleNumber.Value * LoadedScreen.Width);
            Int32 LimitY = (int)(ScaleNumber.Value * LoadedScreen.Height);

            if (IsPressed && e.Location.X <= LimitX + DrawingOffsetHorizontal && e.Location.Y + DrawingOffsetVertical <= LimitY && e.Location.X > DrawingOffsetHorizontal && e.Location.Y > 0)
            {
                CursorPosition.Text = String.Format("[{0}, {1}]", (Math.Floor((e.Location.X - DrawingOffsetHorizontal) / ScaleNumber.Value)), (Math.Floor(e.Location.Y / ScaleNumber.Value)));
                UInt16 x = ((UInt16)(Math.Floor((e.Location.X - DrawingOffsetHorizontal) / ScaleNumber.Value)));
                UInt16 y = ((UInt16)(Math.Floor((e.Location.Y - DrawingOffsetVertical) / ScaleNumber.Value)));
                SetPixel(x, y, this.ActiveButton);
                SolidBrush sb = new SolidBrush(Color.LightBlue);
                Graphics   g  = DrawingArea.CreateGraphics();
                g.FillRectangle(sb, ((float)(x * ScaleNumber.Value)) + DrawingOffsetHorizontal, ((float)(y * ScaleNumber.Value)) + DrawingOffsetVertical, ((float)(ScaleNumber.Value)), ((float)(ScaleNumber.Value)));
            }
        }
Ejemplo n.º 26
0
        protected override void OnKeyDown(DrawingArea canvas, KeyPressEventArgs args)
        {
            // Don't handle the arrow keys while already interacting via the mouse.
            if (using_mouse)
            {
                base.OnKeyDown(canvas, args);
                return;
            }

            double dx = 0.0;
            double dy = 0.0;

            switch (args.Event.Key)
            {
            case Gdk.Key.Left:
                dx = -1;
                break;

            case Gdk.Key.Right:
                dx = 1;
                break;

            case Gdk.Key.Up:
                dy = -1;
                break;

            case Gdk.Key.Down:
                dy = 1;
                break;

            default:
                // Otherwise, let the key be handled elsewhere.
                base.OnKeyDown(canvas, args);
                return;
            }

            if (!IsActive)
            {
                is_dragging = true;
                OnStartTransform();
            }

            transform.Translate(dx, dy);
            OnUpdateTransform(transform);

            args.RetVal = true;
        }
Ejemplo n.º 27
0
	public static void Main ()
	{
		Application.Init ();

		DrawingArea da = new DrawingArea ();
		da.DoubleBuffered = false;
		da.ExposeEvent += ExposeHandler;

		Window win = new Window ("Glitz#");
		win.Add (da);
		win.ShowAll ();

		surface = SetUp (da.GdkWindow);
		cr = new Cairo.Context (surface);

		Application.Run ();
	}
Ejemplo n.º 28
0
        /// <param name="window">A Gtk.Window which will hold a DrawingArea onto which the game will be drawn.</param>
        public GtkGameController(Gtk.Window window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            _area = CreateDrawingSurface(window);

            var createProcedure = new CreateTwoWayTrafficObjects();
            var factory         = new GtkGameObjectFactory(_area, CreateKeyMapper(window));
            var gameProcedures  = new IGameCycleProcedure[] { new MoveAutomatedObjects(), new IfPlayerWinsThenRespawn(), new IfPlayerLosesThenStain() };

            _engine = new GameEngine(createProcedure, factory, gameProcedures);

            _engine.InitialiseGame();
        }
Ejemplo n.º 29
0
        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;
        }
Ejemplo n.º 30
0
        private void scene_design(DrawingArea area, Cairo.Context cr)
        {
            area.AddEvents((int)Gdk.EventMask.ButtonPressMask);
            area.ButtonPressEvent += delegate(object o, ButtonPressEventArgs arg) {
                area.GetPointer(out xo, out yo);
                pressed = true;
            };

            area.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
            area.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args) {
                pressed = false;
                UpdateViewSurface();
            };


            if (pressed)
            {
                area.GetPointer(out xt, out yt);
                if (ventana.circulo.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(0, 0, 1, 0.5);
                    cr.Arc(xo, yo, Constantes.distancia(xt, xo), 0, Math.PI * 2);
                    cr.Stroke();
                }
                else if (ventana.linea.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(0, 1, 0, 0.5);
                    cr.MoveTo(xo, yo);
                    cr.LineTo(xt, yt);
                    cr.Stroke();
                }
                else if (ventana.rectangulo.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(1, 0, 0, 0.5);
                    cr.Rectangle(xo, yo, xt - xo, yt - yo);
                    cr.Stroke();
                }
            }

            cr.SetSourceSurface(Constantes.viewSurface, 0, 0);
            cr.Paint();
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectedGraphView" /> class.
        /// </summary>
        public DirectedGraphView(ViewBase owner = null) : base(owner)
        {
            drawable = new DrawingArea();
            drawable.AddEvents(
                (int)Gdk.EventMask.PointerMotionMask
                | (int)Gdk.EventMask.ButtonPressMask
                | (int)Gdk.EventMask.ButtonReleaseMask);

#if NETFRAMEWORK
            drawable.ExposeEvent += OnDrawingAreaExpose;
#else
            drawable.Drawn += OnDrawingAreaExpose;
#endif
            drawable.ButtonPressEvent   += OnMouseButtonPress;
            drawable.ButtonReleaseEvent += OnMouseButtonRelease;
            drawable.MotionNotifyEvent  += OnMouseMove;

            ScrolledWindow scroller = new ScrolledWindow()
            {
                HscrollbarPolicy = PolicyType.Always,
                VscrollbarPolicy = PolicyType.Always
            };

#if NETFRAMEWORK
            scroller.AddWithViewport(drawable);
#else
            // In gtk3, a viewport will automatically be added if required.
            scroller.Add(drawable);
#endif

            mainWidget              = scroller;
            drawable.Realized      += OnRealized;
            drawable.SizeAllocated += OnRealized;
            if (owner == null)
            {
                DGObject.DefaultOutlineColour = OxyPlot.OxyColors.Black;
            }
            else
            {
                // Needs to be reimplemented for gtk3.
                DGObject.DefaultOutlineColour    = Utility.Colour.GtkToOxyColor(owner.MainWidget.GetForegroundColour(StateType.Normal));
                DGObject.DefaultBackgroundColour = Utility.Colour.GtkToOxyColor(owner.MainWidget.GetBackgroundColour(StateType.Normal));
            }
            mainWidget.Destroyed += OnDestroyed;
        }
Ejemplo n.º 32
0
        ColourExample()
        {
            FindColors();
            win = new Window("Strawberry Reds");
            win.SetDefaultSize(610, 70);
            win.DeleteEvent += OnWinDelete;

            da              = new DrawingArea();
            da.ExposeEvent += OnExposed;

            Gdk.Color col = new Gdk.Color();
            Gdk.Color.Parse("red", ref col);
            win.ModifyBg(StateType.Normal, col);
            da.ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128));

            win.Add(da);
            win.ShowAll();
        }
Ejemplo n.º 33
0
        /// <summary>The drawing canvas is being exposed to user.</summary>
        private void OnDrawingAreaExpose(object sender, ExposeEventArgs args)
        {
            DrawingArea area = (DrawingArea)sender;

            Cairo.Context context = Gdk.CairoHelper.Create(area.GdkWindow);

            foreach (DGArc tmpArc in Arcs)
            {
                tmpArc.Paint(context);
            }
            foreach (DGNode tmpNode in Nodes)
            {
                tmpNode.Paint(context);
            }

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Ejemplo n.º 34
0
        protected virtual void OnPreviewDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            DrawingArea area = (DrawingArea)o;

            if (designService.Report.Pages.Count > 0)
            {
                Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
                cr.Antialias           = Cairo.Antialias.None;
                reportRenderer.Context = cr;
                Cairo.Rectangle r = new Cairo.Rectangle(0, 0, designService.Report.WidthWithMargins, designService.Report.HeightWithMargins);
                cr.FillRectangle(r, backgroundPageColor);
                cr.Translate(designService.Report.Margin.Left, designService.Report.Margin.Top);
                reportRenderer.RenderPage(designService.Report.Pages [pageNumber]);
                area.SetSizeRequest((int)designService.Report.HeightWithMargins, (int)designService.Report.HeightWithMargins + 5);

                (cr as IDisposable).Dispose();
            }
        }
Ejemplo n.º 35
0
        void AddExtraControlsSeparator()
        {
            projectConfigurationTable.NRows++;

            extraControlsSeparator = new DrawingArea();
            extraControlsSeparator.HeightRequest = 1;
            extraControlsSeparator.ModifyBg(StateType.Normal, separatorColor);
            projectConfigurationTable.Attach(
                extraControlsSeparator,
                0,
                3,
                defaultTableRows,
                defaultTableRows + 1,
                AttachOptions.Fill,
                (AttachOptions)0,
                0,
                10);
        }
Ejemplo n.º 36
0
    /// <summary>
    /// Constructs the sprite drawing area, along with the various
    /// rules needed.
    /// </summary>
    public DemoSprites()
    {
        // Create the drop-down list
        HBox box = new HBox();

        paneList          = ComboBox.NewText();
        paneList.Changed += OnPaneChanged;
        fps          = new SpinButton(1, 100, 1);
        fps.Value    = DesiredFps;
        fps.Changed += OnFpsChanged;
        showUpdate   = new CheckButton();
        box.PackStart(paneList, false, false, 0);
        box.PackStart(new Label("FPS"), false, false, 5);
        box.PackStart(fps, false, false, 2);
        box.PackStart(new Label("Show Update"), false, false, 5);
        box.PackStart(showUpdate, false, false, 2);
        box.PackStart(new Label(), true, true, 0);
        PackStart(box, false, false, 2);

        // Create the drawing area and pack it
        area                 = new DrawingArea();
        area.Realized       += OnRealized;
        area.ExposeEvent    += OnExposed;
        area.ConfigureEvent += OnConfigure;
        PackStart(area, true, true, 2);

        // Set up the search paths for the factory. We need to do this
        // before the sprite pane loading because the panes use the
        // factory for their own loading.
        string dataPath = AppDomain.CurrentDomain.BaseDirectory + "/images";

        PixbufFactory.SearchPaths.Add(new DirectoryInfo(dataPath));

        string   tilesetPath = System.IO.Path.Combine(dataPath, "tileset.xml");
        FileInfo tilesetFile = new FileInfo(tilesetPath);

        TilesetFactory.Load(tilesetFile);

        // Use reflection to load the demos in random order
        LoadSpritePanes();

        // Start up a little animation loop
        Timeout.Add(1000 / DesiredFps, OnTick);
    }
Ejemplo n.º 37
0
        static void Main(string[] args)
        {
            var assembly    = typeof(Program).Assembly;
            var fileVersion = assembly.GetCustomAttribute <AssemblyFileVersionAttribute>();

#if DEBUG
            var buildType = "Debug";
#else
            var buildType = "Release";
#endif
            Console.WriteLine($"OpenPackage (HydraEd {fileVersion.Version}/{buildType})");

            if (args.Length == 0)
            {
                Console.WriteLine("Error: Run this tool again with the file path specified.");
                return;
            }
            var filename = string.Join(' ', args);
            using var file = File.OpenRead(filename);
            var package = new Package(file);

            Application.Init();

            var app = new Application("com.alex.hydra.devtool", GLib.ApplicationFlags.None);
            app.Register(GLib.Cancellable.Current);

            var win         = new Window(WindowType.Toplevel);
            var drawingArea = new DrawingArea();
            win.SetSizeRequest(256, 256);
            drawingArea.SetSizeRequest(256, 256);

            var actorTree   = new ActorTree(package);
            var gtkRenderer = new GtkRenderer(drawingArea);
            var hydra       = new HydraEngine(actorTree, gtkRenderer);
            gtkRenderer.LinkTo(hydra);
            win.DeleteEvent += (object sender, DeleteEventArgs args) => { Application.Quit(); };

            win.Child = drawingArea;
            app.AddWindow(win);
            win.ShowAll();
            drawingArea.QueueDraw();

            Application.Run();
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Draws the graph on a canvas.
        /// </summary>
        /// <param name="Canvas">Canvas to draw on.</param>
        /// <param name="Points">Points to draw.</param>
        /// <param name="Parameters">Graph-specific parameters.</param>
        /// <param name="PrevPoints">Points of previous graph of same type (if available), null (if not available).</param>
        /// <param name="PrevParameters">Parameters of previous graph of same type (if available), null (if not available).</param>
        /// <param name="DrawingArea">Current drawing area.</param>
        public void DrawGraph(SKCanvas Canvas, SKPoint[] Points, object[] Parameters, SKPoint[] PrevPoints, object[] PrevParameters,
                              DrawingArea DrawingArea)
        {
            SKPaint Pen  = null;
            SKPath  Path = null;

            try
            {
                Pen  = Graph.ToPen(Parameters[0], Parameters[1]);
                Path = CreateSpline(Points);

                Canvas.DrawPath(Path, Pen);
            }
            finally
            {
                Pen?.Dispose();
                Path?.Dispose();
            }
        }
Ejemplo n.º 39
0
    public static void Main()
    {
        Application.Init();

        DrawingArea da = new DrawingArea();

        da.DoubleBuffered = false;
        da.ExposeEvent   += ExposeHandler;

        Window win = new Window("Glitz#");

        win.Add(da);
        win.ShowAll();

        surface = SetUp(da.GdkWindow);
        cr      = new Cairo.Context(surface);

        Application.Run();
    }
Ejemplo n.º 40
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        // Setup Emulator
        emulator = new CHIP8_Emulator.Chip8();
        emulator.Load("../../ROMS/PONG2");

        // Register our timer function
        hiResTimer.MicroTimerElapsed += new MicroTimer.MicroTimerElapsedEventHandler(hiResTick);
        hiResTimer.Enabled = true;

        // Install drawing area
        da = new DrawingArea();
        Add (da);
        da.Show();

        // Setup drawing function
        da.ExposeEvent += ScreenExposeEvent;
    }
Ejemplo n.º 41
0
    void Start()
    {
        ZLog.Log ("SampleCodeUse Start() method, Screen.height: " + Screen.height + " Screen.width: " + Screen.width);

        mDrawingAreaRect = new Rect ((Screen.width / 2) - 150, 0, 150, 150);
        mDrawActivityRect = new Rect ((Screen.width / 2) + 50, 0, 150, 150);

        byte[] bgImage;
        if (imageTexture != null) {
            bgImage = imageTexture.EncodeToPNG ();
        } else {
            bgImage = null;
        }

        //Let's ask Java for the Drawing Area
        mDrawingArea = DrawingArea.getInstance (this, false, bgImage);
        mDrawingArea.setSize (DrawingArea.WRAP_CONTENT, Screen.height / 2);
        mDrawingArea.setButtonVisibility (true, true, true, true, true, true, true, true, true);

        ZLog.Log ("SampleCodeUse Start() method - end");
    }
Ejemplo n.º 42
0
		public CairoSnippetsGtk ()
		{
			Window w = new Window ("Cairo snippets");
			w.SetDefaultSize (width, height);
			w.DeleteEvent += delegate { Application.Quit (); };

			HPaned hpane = new HPaned ();
			ScrolledWindow sw = new ScrolledWindow ();
			TreeView tv = new TreeView ();
			tv.HeadersVisible = false;
			tv.AppendColumn ("snippets", new CellRendererText (), "text", 0);
			tv.Model = GetModel ();
			tv.Selection.Changed += OnSelectionChanged;
			sw.Add (tv);
			hpane.Add1 (sw);
			da = new DrawingArea ();
			da.ExposeEvent += OnExposed;
			hpane.Add2 (da);
			hpane.Position = width / 2;
			w.Add (hpane);
			
			w.ShowAll ();
		}
Ejemplo n.º 43
0
    /**
     * Returns the instance of DrawingArea class with default values of button visibility settings.
     *
     * @param caller The calling object, to be used for callbacks.
     * @param pOnlyIncludeForeground If true, only foreground of the drawn image will be returned as a result of this activity. If false, also
     * background will be included.
     * @param bgImage Background image to be set in the canvas view.
     */
    public static DrawingArea getInstance(DrawingAreaOnResult caller, bool pOnlyIncludeForeground, byte[] bgImage)
    {
        ZLog.Log ("DrawingArea getInstance start");
        if (caller == null)
            return null;

        if ((mSPenManager = GameObject.Find("_SPenManager")) == null) {
            ZLog.Log ("DrawingArea getInstance - creating manager game object.");
            mSPenManager = new GameObject ("_SPenManager");
            AndroidJNI.AttachCurrentThread ();
            AndroidJNIHelper.debug = true;
        }

        if ((mInstance = mSPenManager.GetComponent<DrawingArea> ()) == null) {
            ZLog.Log ("DrawingArea getInstance - adding component to manager game object.");
            mInstance = mSPenManager.AddComponent<DrawingArea> ();
            mInstance.init (bgImage);
        } else {
            if (bgImage != null) {
                mInstance.setBackgroundImage (bgImage);
            }
        }

        mInstance.mCaller = caller;
        mInstance.mOnlyIncludeForeground = pOnlyIncludeForeground;

        ZLog.Log ("DrawingArea getInstance end");
        return mInstance;
    }
Ejemplo n.º 44
0
    /// <summary>
    /// Constructs the sprite drawing area, along with the various
    /// rules needed.
    /// </summary>
    public DemoSprites()
    {
        // Create the drop-down list
        HBox box = new HBox();
        paneList = ComboBox.NewText();
        paneList.Changed += OnPaneChanged;
        fps = new SpinButton(1, 100, 1);
        fps.Value = DesiredFps;
        fps.Changed += OnFpsChanged;
        showUpdate = new CheckButton();
        box.PackStart(paneList, false, false, 0);
        box.PackStart(new Label("FPS"), false, false, 5);
        box.PackStart(fps, false, false, 2);
        box.PackStart(new Label("Show Update"), false, false, 5);
        box.PackStart(showUpdate, false, false, 2);
        box.PackStart(new Label(), true, true, 0);
        PackStart(box, false, false, 2);

        // Create the drawing area and pack it
        area = new DrawingArea();
        area.Realized += OnRealized;
        area.ExposeEvent += OnExposed;
        area.ConfigureEvent += OnConfigure;
        PackStart(area, true, true, 2);

        // Set up the search paths for the factory. We need to do this
        // before the sprite pane loading because the panes use the
        // factory for their own loading.
        string dataPath = AppDomain.CurrentDomain.BaseDirectory + "/images";
        PixbufFactory.SearchPaths.Add(new DirectoryInfo(dataPath));

        string tilesetPath = System.IO.Path.Combine(dataPath, "tileset.xml");
        FileInfo tilesetFile = new FileInfo(tilesetPath);
        TilesetFactory.Load(tilesetFile);

        // Use reflection to load the demos in random order
        LoadSpritePanes();

        // Start up a little animation loop
        Timeout.Add(1000 / DesiredFps, OnTick);
    }
Ejemplo n.º 45
0
 protected void onDAExposed(object o, ExposeEventArgs args)
 {
     circuitAera = (DrawingArea)o;
 }
Ejemplo n.º 46
0
 public void Draw(DrawingArea canvas)
 {
 }
Ejemplo n.º 47
0
 HermitePoint CreateHermitePoint(Color col)
 {
     var cp1 = new DrawingArea ();
     cp1.ModifyBg (StateType.Normal, col);
     cp1.SetSizeRequest (20, 20);
     cp1.AddEvents ((int)EventMask.AllEventsMask);
     fixed3.Add (cp1);
     cp1.Show ();
     bool drag = false;
     Point p = new Point();
     cp1.MotionNotifyEvent += (o, args) => {
         if (drag) {
             int x, y;
             cp1.GdkWindow.GetPosition (out x, out y);
             cp1.GdkWindow.Move (
                 (int)args.Event.X + x - p.X,
                 (int)args.Event.Y + y - p.Y
             );
         }
         canvas.QueueDraw ();
     };
     cp1.ButtonPressEvent += (o, args) => {
         drag = true;
         p = new Point ((int)args.Event.X, (int)args.Event.Y);
     };
     cp1.ButtonReleaseEvent += (o, args) => {
         drag = false;
     };
     return new HermitePoint (){Area = cp1 };
 }