/* * invaders constructor, creates a 512x512 game window and calls the * update handler every 1/10 of a second. */ invaders() { /* 100/1000 is the 1/10 second time interval. */ mytimer = GLib.Timeout.Add(100, new GLib.TimeoutHandler(update_handler)); win = new Gtk.Window("Space Invaders"); win.SetDefaultSize(window_size, window_size); win.SetPosition(WindowPosition.Center); /* add what to do when a delete event is processed. */ win.DeleteEvent += new DeleteEventHandler(handle_quit); area = new DrawingArea(); area.AddEvents((int) (EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask)); area.AddEvents((int)EventMask.ButtonPressMask); area.ButtonPressEvent += new ButtonPressEventHandler(MyHandler); System.Console.WriteLine("before win.Add"); win.Add(area); System.Console.WriteLine("before win.ShowAll"); win.ShowAll(); System.Console.WriteLine("before context"); context = Gdk.CairoHelper.Create(area.GdkWindow); System.Console.WriteLine("finish gamewindow"); }
ISheet IDesigner.AddSheet(string Label, ISheet sheet) { if (this.Sheet == null) { Canvas = new DrawingArea(); Canvas.AddEvents((int)Gdk.EventMask.ButtonPressMask); Canvas.AddEvents((int)Gdk.EventMask.ButtonReleaseMask); Canvas.AddEvents((int)Gdk.EventMask.PointerMotionMask); // Canvas.ButtonPressEvent += HandleButtonPressEvent; Canvas.ButtonReleaseEvent += HandleButtonReleaseEvent; Canvas.ExposeEvent += HandleExposeEvent; Canvas.MotionNotifyEvent += HandleMotionNotifyEvent; Gtk.Drag.DestSet( Canvas, DestDefaults.All, new Gtk.TargetEntry[] { new Gtk.TargetEntry("application/x-solidide.shape", Gtk.TargetFlags.App, 0) }, Gdk.DragAction.Copy ); Canvas.DragDataReceived += HandleCanvasDragDataReceived; // noteBook.AppendPage(Canvas, new Gtk.Label(Label)); noteBook.ShowAll(); //Canvas.Show(); } this.Sheet = sheet as Sheet <Gdk.Event, Cairo.Context, SolidV.MVC.Model>; return(sheet); }
public WidgetWrapper(DrawingArea widget) { this.widget = widget; MoveWaitMS = 200; widget.AddEvents((int)EventMask.PointerMotionMask); widget.AddEvents((int)EventMask.ButtonPressMask); widget.AddEvents((int)EventMask.ButtonReleaseMask); widget.AddEvents((int)EventMask.KeyPressMask); widget.ExposeEvent += HandleExposeEvent; widget.ButtonPressEvent += HandleButtonPressEvent; widget.ButtonReleaseEvent += HandleButtonReleaseEvent; widget.MotionNotifyEvent += HandleMotionNotifyEvent; }
/// <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); drawable.ExposeEvent += OnDrawingAreaExpose; drawable.ButtonPressEvent += OnMouseButtonPress; drawable.ButtonReleaseEvent += OnMouseButtonRelease; drawable.MotionNotifyEvent += OnMouseMove; ScrolledWindow scroller = new ScrolledWindow(new Adjustment(0, 0, 100, 1, 1, 1), new Adjustment(0, 0, 100, 1, 1, 1)) { HscrollbarPolicy = PolicyType.Always, VscrollbarPolicy = PolicyType.Always }; scroller.AddWithViewport(drawable); _mainWidget = scroller; drawable.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255)); drawable.Realized += OnRealized; }
// 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(); }
public MainWindow() : base("Obake Meiro") { ReadConfig(); var asm = System.Reflection.Assembly.GetExecutingAssembly(); player = new Gdk.Pixbuf(asm.GetManifestResourceStream("PlayerImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); wall = new Gdk.Pixbuf(asm.GetManifestResourceStream("WallImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); white = new Gdk.Pixbuf(asm.GetManifestResourceStream("WhiteImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); goal = new Gdk.Pixbuf(asm.GetManifestResourceStream("GoalImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); obake = new Gdk.Pixbuf(asm.GetManifestResourceStream("ObakeImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); bat = new Gdk.Pixbuf(asm.GetManifestResourceStream("BatImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); kasa = new Gdk.Pixbuf(asm.GetManifestResourceStream("KasaImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); mummy = new Gdk.Pixbuf(asm.GetManifestResourceStream("MummyImage")).ScaleSimple(size, size, Gdk.InterpType.Bilinear); //SetDefaultSize((width + 2) * size, (height + 2) * size); //margin.x = 0; margin.y = 0; Fullscreen(); margin.x = (Screen.Width - (width + 2) * size) / 2; margin.y = (Screen.Height - (height + 2) * size) / 2; map = new Cell[width, height]; current = new Pos(0, 0); Start(); area = new DrawingArea(); area.AddEvents((int)Gdk.EventMask.PointerMotionMask); area.ExposeEvent += OnExpose; area.MotionNotifyEvent += OnMotion; Add(area); KeyPressEvent += OnKeyPress; DeleteEvent += OnDeleteEvent; ShowAll(); }
/// <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); drawable.ExposeEvent += OnDrawingAreaExpose; drawable.ButtonPressEvent += OnMouseButtonPress; drawable.ButtonReleaseEvent += OnMouseButtonRelease; drawable.MotionNotifyEvent += OnMouseMove; ScrolledWindow scroller = new ScrolledWindow(new Adjustment(0, 0, 100, 1, 1, 1), new Adjustment(0, 0, 100, 1, 1, 1)) { HscrollbarPolicy = PolicyType.Always, VscrollbarPolicy = PolicyType.Always }; scroller.AddWithViewport(drawable); mainWidget = scroller; drawable.Realized += OnRealized; if (owner == null) { DGObject.DefaultOutlineColour = OxyPlot.OxyColors.Black; } else { DGObject.DefaultOutlineColour = Utility.Colour.GtkToOxyColor(owner.MainWidget.Style.Foreground(StateType.Normal)); DGObject.DefaultBackgroundColour = Utility.Colour.GtkToOxyColor(owner.MainWidget.Style.Background(StateType.Normal)); } }
public VideoWindow() { this.Build(); frame = new AspectFrame(null, 0.5f, 0.5f, 1f, false); frame.Shadow = ShadowType.None; messageLabel.NoShowAll = true; drawingWindow = new DrawingArea(); drawingWindow.DoubleBuffered = false; drawingWindow.ExposeEvent += HandleExposeEvent; drawingWindow.MotionNotifyEvent += HandleMotionNotifyEvent; drawingWindow.ButtonPressEvent += HandleButtonPressEvent; drawingWindow.ButtonReleaseEvent += HandleButtonReleaseEvent; drawingWindow.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.ScrollMask)); videoeventbox.ButtonPressEvent += HandleButtonPressEvent; videoeventbox.ButtonReleaseEvent += HandleButtonReleaseEvent; videoeventbox.ScrollEvent += HandleScrollEvent; videoeventbox.BorderWidth = 0; if (Environment.OSVersion.Platform == PlatformID.Win32NT) { // Workaround for GTK bugs on Windows not showing the video window videoeventbox.VisibilityNotifyEvent += HandleVisibilityNotifyEvent; } frame.Add(drawingWindow); videoeventbox.Add(frame); videoeventbox.ShowAll(); MessageVisible = false; }
/// <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); drawable.Drawn += OnDrawingAreaExpose; drawable.ButtonPressEvent += OnMouseButtonPress; drawable.ButtonReleaseEvent += OnMouseButtonRelease; drawable.MotionNotifyEvent += OnMouseMove; ScrolledWindow scroller = new ScrolledWindow() { HscrollbarPolicy = PolicyType.Always, VscrollbarPolicy = PolicyType.Always }; // In gtk3, a viewport will automatically be added if required. scroller.Add(drawable); mainWidget = scroller; drawable.Realized += OnRealized; drawable.SizeAllocated += OnRealized; mainWidget.Destroyed += OnDestroyed; }
public TernaryGraphView(ViewBase owner) : base(owner) { HBox container = new HBox(); chart = new DrawingArea(); chart.AddEvents((int)Gdk.EventMask.ExposureMask | (int)Gdk.EventMask.PointerMotionMask | (int)Gdk.EventMask.ButtonPressMask | (int)Gdk.EventMask.ButtonReleaseMask); chart.Drawn += OnDrawChart; chart.ButtonPressEvent += OnMouseButtonPress; chart.ButtonReleaseEvent += OnMouseButtonRelease; chart.MotionNotifyEvent += OnMouseMove; container.PackStart(chart, true, true, 0); xlabel = new Label(); ylabel = new Label(); zlabel = new Label(); VBox labels = new VBox(); labels.PackStart(xlabel, false, false, 0); labels.PackStart(ylabel, false, false, 0); labels.PackStart(zlabel, false, false, 0); container.PackStart(labels, true, true, 0); mainWidget = container; mainWidget.Hide(); }
/// <summary> /// Default Constructor /// </summary> public InteractivePlotSurface2D() : base() { canvas = new DrawingArea(); // allocate local DrawingArea canvas.CanFocus = true; // enable to receive the focus // Link the event handlers into the DrawingArea events (default is none) canvas.SizeAllocated += new SizeAllocatedHandler(SizeAllocated); canvas.ExposeEvent += new ExposeEventHandler(ExposeEvent); canvas.EnterNotifyEvent += new EnterNotifyEventHandler(EnterNotify); canvas.LeaveNotifyEvent += new LeaveNotifyEventHandler(LeaveNotify); canvas.ButtonPressEvent += new ButtonPressEventHandler(ButtonPress); canvas.MotionNotifyEvent += new MotionNotifyEventHandler(MotionNotify); canvas.ButtonReleaseEvent += new ButtonReleaseEventHandler(ButtonRelease); canvas.ScrollEvent += new ScrollEventHandler(ScrollNotify); canvas.KeyPressEvent += new KeyPressEventHandler(KeyPressed); canvas.KeyReleaseEvent += new KeyReleaseEventHandler(KeyReleased); // Subscribe to DrawingArea mouse movement and button press events. // Enter and Leave notification is necessary to make ToolTips work. // Specify PointerMotionHint to prevent being deluged with motion events. canvas.AddEvents((int)Gdk.EventMask.EnterNotifyMask); canvas.AddEvents((int)Gdk.EventMask.LeaveNotifyMask); canvas.AddEvents((int)Gdk.EventMask.ButtonPressMask); canvas.AddEvents((int)Gdk.EventMask.ButtonReleaseMask); canvas.AddEvents((int)Gdk.EventMask.PointerMotionMask); canvas.AddEvents((int)Gdk.EventMask.PointerMotionHintMask); canvas.AddEvents((int)Gdk.EventMask.ScrollMask); canvas.SetSizeRequest(400, 300); // Set DrawingArea size // Set up ToolTips to show coordinates. NB works via Enter/Leave events // TODO: ToolTips do not work well yet - needs review of approach this.Canvas.TooltipText = "Coordinates will display here"; }
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(); }
public gamewindow() { System.Console.WriteLine("inside gamewindow"); win = new Gtk.Window("Breakout"); win.SetDefaultSize(breakout_definitions.x_win, breakout_definitions.y_win); win.SetPosition(WindowPosition.Center); DeleteEvent += delegate { Application.Quit(); }; area = new DrawingArea(); area.AddEvents((int)(EventMask.ButtonPressMask | EventMask.ButtonReleaseMask)); area.ExposeEvent += OnDrawingAreaExposed; area.KeyPressEvent += new KeyPressEventHandler(key_handler); area.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler); area.ButtonReleaseEvent += new ButtonReleaseEventHandler(ButtonReleaseHandler); MenuBar mb = new MenuBar(); Menu file_menu = new Menu(); MenuItem file = new MenuItem("File"); file.Submenu = file_menu; MenuItem run = new MenuItem("Run"); run.Activated += do_run; file_menu.Append(run); MenuItem exit = new MenuItem("Exit"); exit.Activated += do_exit; file_menu.Append(exit); mb.Append(file); VBox vbox = new VBox(false, 3); vbox.PackStart(mb, false, false, 0); HBox hbox = new HBox(); hbox.Add(area); vbox.Add(hbox); System.Console.WriteLine("before win.Add"); win.Add(vbox); System.Console.WriteLine("before win.ShowAll"); win.ShowAll(); System.Console.WriteLine("before context"); context = Gdk.CairoHelper.Create(area.GdkWindow); System.Console.WriteLine("finish gamewindow"); }
/// <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)); }
/// <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; }
/// <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); drawable.Drawn += OnDrawingAreaExpose; drawable.ButtonPressEvent += OnMouseButtonPress; drawable.ButtonReleaseEvent += OnMouseButtonRelease; drawable.MotionNotifyEvent += OnMouseMove; ScrolledWindow scroller = new ScrolledWindow() { HscrollbarPolicy = PolicyType.Always, VscrollbarPolicy = PolicyType.Always }; // In gtk3, a viewport will automatically be added if required. scroller.Add(drawable); mainWidget = scroller; drawable.Realized += OnRealized; drawable.SizeAllocated += OnRealized; if (owner == null) { DGObject.DefaultOutlineColour = Color.Black; } else { // Needs to be reimplemented for gtk3. DGObject.DefaultOutlineColour = owner.MainWidget.StyleContext.GetColor(StateFlags.Normal).ToColour(); #pragma warning disable 0612 DGObject.DefaultBackgroundColour = owner.MainWidget.StyleContext.GetBackgroundColor(StateFlags.Normal).ToColour(); #pragma warning restore 0612 } mainWidget.Destroyed += OnDestroyed; }
public Paint() : base("Painting application") { surface = new ImageSurface(Format.Argb32, 500, 500); area = new DrawingArea(); area.AddEvents( (int)Gdk.EventMask.PointerMotionMask | (int)Gdk.EventMask.ButtonPressMask | (int)Gdk.EventMask.ButtonReleaseMask); area.ExposeEvent += OnDrawingAreaExposed; area.ButtonPressEvent += OnMousePress; area.ButtonReleaseEvent += OnMouseRelease; area.MotionNotifyEvent += OnMouseMotion; DeleteEvent += delegate { Application.Quit(); }; Painter = new DrawShape(DrawLine); Start = new PointD(0.0, 0.0); End = new PointD(500.0, 500.0); isDrawing = false; isDrawingPoint = false; SetDefaultSize(500, 500); SetPosition(WindowPosition.Center); VBox vbox = new VBox(); vbox.Add(area); HBox hbox = new HBox(); line = new Button("Line"); pen = new Button("Pen"); hbox.Add(line); hbox.Add(pen); Alignment halign = new Alignment(1, 0, 0, 0); halign.Add(hbox); vbox.Add(hbox); vbox.PackStart(halign, false, false, 3); line.Clicked += LineClicked; pen.Clicked += PenClicked; Add(vbox); Add(area); ShowAll(); }
public SharpApp() : base("Center") { //Backend Dude stuff Thing.init(world); Dude.SpawnDudes(1); specialThing = new Thing(); specialThing.red = 1; specialThing.green = 1; specialThing.blue = 1; //Gtk and Cairo things SetDefaultSize(400, 400); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Application.Quit(); }; darea.ExposeEvent += OnExpose; darea.AddEvents((int) (EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask)); darea.MotionNotifyEvent += delegate(object o, MotionNotifyEventArgs args) { specialThing.spacials.pos.X = args.Event.X - (darea.Allocation.Width / 2); specialThing.spacials.pos.Y = args.Event.Y - (darea.Allocation.Height / 2); }; Add(darea); ShowAll(); //loop (); //ThreadPool.QueueUserWorkItem(new WaitCallback(loop)); GLib.Timeout.Add(14, new GLib.TimeoutHandler(OnTimer)); }
private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow")) { this.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly().GetManifestResourceStream("LoopMusicPlayer.icon.ico")); Bass.Init(); Bass.Configure(Configuration.UpdatePeriod, 1); Bass.Configure(Configuration.PlaybackBufferLength, 50); builder.Autoconnect(this); _seekbararea.AddTickCallback(onframetick); TitleNameCell = new Gtk.CellRendererText(); TimeCell = new Gtk.CellRendererText(); LoopCell = new Gtk.CellRendererText(); ArtistNameCell = new Gtk.CellRendererText(); PathCell = new Gtk.CellRendererText(); _titlecolumn.PackStart(TitleNameCell, true); _timecolumn.PackStart(TimeCell, true); _loopcolumn.PackStart(LoopCell, true); _artistcolumn.PackStart(ArtistNameCell, true); _pathcolumn.PackStart(PathCell, true); _titlecolumn.AddAttribute(TitleNameCell, "text", 0); _timecolumn.AddAttribute(TimeCell, "text", 1); _loopcolumn.AddAttribute(LoopCell, "text", 2); _artistcolumn.AddAttribute(ArtistNameCell, "text", 3); _pathcolumn.AddAttribute(PathCell, "text", 4); DeleteEvent += Window_DeleteEvent; var targets = new[] { new TargetEntry("text/uri-list", TargetFlags.OtherApp, 0) }; Drag.DestSet(this, DestDefaults.All, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move); DragDataReceived += TreeViewDragDataReceived; this.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask)); _labelseektimemenu.Toggle(); _singlerepeat.Toggle(); _streamingplay.Toggle(); UpdateLoopCountLabel(); _aboutmenu.Activated += ShowAbout; _listaddmenu.Activated += OpenFileFromMenu; _seekbararea.Drawn += DrawingArea_OnDraw; _quitmenu.Activated += WindowQuit; _listclearmenu.Activated += ListClear; _listdeletemenu.Activated += ListDelete; _treeview.RowActivated += ActivateLow; _volumebutton.ValueChanged += VolumeChanged; _pausebutton.Clicked += PauseClicked; _stopbutton.Clicked += StopClicked; _playbutton.Clicked += PlayClicked; _previousbutton.Clicked += PreviousClicked; _nextbutton.Clicked += NextClicked; _ejectbutton.Clicked += EjectClicked; _streamingplay.Toggled += EjectClicked; _onmemoryplay.Toggled += EjectClicked; _seekbararea.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask)); _seekbararea.ButtonPressEvent += SeekBarButtonPress; _seekbararea.ButtonReleaseEvent += SeekBarButtonRelease; _windowkeepabovemenu.Toggled += WindowAboveToggled; _showgridlinemenu.Toggled += ShowGridMenuToggled; _loopcountupbutton.Clicked += LoopCountUpButtonClicked; _loopcountdownbutton.Clicked += LoopCountDownButtonClicked; _singleplay.Toggled += LoopMethodToggled; _singlerepeat.Toggled += LoopMethodToggled; _allrepeat.Toggled += LoopMethodToggled; _randomplay.Toggled += LoopMethodToggled; }
//Contains all of the components which are on the window private void setupWindow() { //Vertical box (3 sections) which is the main container VBox MainVBox = new VBox(false, 6); /*********************Start of menu bar components*********************/ //Note: Flow of menus are: //Menubar contains MenuItems (e.g. File, Edit, About, etc...) //MenuItems contains one Menu (i.e. a Submenu) //Menu contains multiple MenuItems (e.g. Save, Save As, Load, etc...) MenuBar MainMenuBar = new MenuBar(); Menu FileMenu = new Menu(); MenuItem File = new MenuItem("File"); File.Submenu = FileMenu; MenuItem ExitItem = new MenuItem("Exit"); ExitItem.Activated += quitProgram; FileMenu.Append(ExitItem); Menu GestureMenu = new Menu(); MenuItem Gesture = new MenuItem("Gestures"); Gesture.Submenu = GestureMenu; MenuItem LoadGesture = new MenuItem("Load Gesture"); LoadGesture.Activated += openGesture; GestureMenu.Append(LoadGesture); MenuItem SaveGestureItem = new MenuItem("Save Gesture"); SaveGestureItem.Activated += createGesture; GestureMenu.Append(SaveGestureItem); Menu PointsMenu = new Menu(); MenuItem Points = new MenuItem("Data Points"); Points.Submenu = PointsMenu; MenuItem LoadPointsItem = new MenuItem("Load Points"); LoadPointsItem.Activated += loadDataPoints; PointsMenu.Append(LoadPointsItem); MenuItem RecordPointsItem = new MenuItem("Record Points"); RecordPointsItem.Activated += recordPoints; PointsMenu.Append(RecordPointsItem); MenuItem BatchRecognizeItem = new MenuItem("Batch Recognize"); BatchRecognizeItem.Activated += batchRecognize; PointsMenu.Append(BatchRecognizeItem); Menu HelpMenu = new Menu(); MenuItem Help = new MenuItem("Help"); Help.Submenu = HelpMenu; MenuItem AboutMenuItem = new MenuItem("About"); HelpMenu.Append(AboutMenuItem); MainMenuBar.Append(File); MainMenuBar.Append(Gesture); MainMenuBar.Append(Points); MainMenuBar.Append(Help); /*********************End of menu bar components*********************/ //Drawing area which is the core component of the application dArea = new DrawingArea(); dArea.SetSizeRequest(500, 500); //Horizontal box (4 sections) which contains all of the buttons along the //bottom of the window HBox ButtonHBox = new HBox(false, 6); /*********************Start of Buttons*********************/ Button BtnCreateGesture = new Button("Create"); Button BtnRecognizeGesture = new Button("Recognize"); Button BtnClearScreen = new Button("Clear"); Button BtnRecordPoints = new Button("Record points"); Button BtnChangeColour = new Button("Change colour"); //Button functions BtnCreateGesture.Clicked += new EventHandler(createGesture); BtnRecognizeGesture.Clicked += new EventHandler(recognizeGesture); BtnClearScreen.Clicked += new EventHandler(clearScreen); BtnRecordPoints.Clicked += new EventHandler(recordPoints); BtnChangeColour.Clicked += changeColour; //Adding buttons to the current horizontal box ButtonHBox.PackStart(BtnCreateGesture, true, false, 0); ButtonHBox.PackStart(BtnRecognizeGesture, true, false, 0); ButtonHBox.PackStart(BtnClearScreen, true, false, 0); ButtonHBox.PackStart(BtnRecordPoints, true, false, 0); ButtonHBox.PackStart(BtnChangeColour, true, false, 0); /*********************End of Buttons*********************/ //Status bar which shows the score and recognized gesture sBar = new Statusbar(); sBar.Push(1, "Ready"); //Entry box for batch function name to be used on the files batchFunctionName = new Entry("Recorded points function name"); batchFunctionName.AddEvents( (int)Gdk.EventMask.ButtonPressMask ); batchFunctionName.ButtonPressEvent += clearTextBox; //Adding all components to the Vertical box MainVBox.PackStart(MainMenuBar, false, false, 0); MainVBox.PackStart(dArea, false, false, 0); MainVBox.PackStart(ButtonHBox, false, false, 0); MainVBox.PackStart(batchFunctionName, false, false, 0); MainVBox.PackStart(sBar, false, false, 0); Add(MainVBox); ShowAll(); //Surface 'pattern' for area to be covered surface = new ImageSurface(Format.Argb32, 500, 500); //Adding mouse events to the drawing area and assigning functions dArea.AddEvents( //Mouse Related Events (int)Gdk.EventMask.PointerMotionMask | (int)Gdk.EventMask.ButtonPressMask | (int)Gdk.EventMask.ButtonReleaseMask ); //Repaint the Canvas Internally. dArea.ExposeEvent += OnDrawingAreaExposed; //Do this on MousePress inside Area dArea.ButtonPressEvent += OnMousePress; //Do this on MouseReleased inside Area dArea.ButtonReleaseEvent += OnMouseRelease; //Do this if a Motion Occurs inside the Drawing Area dArea.MotionNotifyEvent += OnMouseMotion2; //Assigning close function to the window DeleteEvent += delegate { Application.Quit(); }; //Checking to see if bool for using the dot function is true //And assigning the required function as the delegate's operation //Note: This will always be true, no current way to switch while //application is running, has not been needed as of yet if (isDot) { Painter = new DrawShape(DrawDot); myoPainter = new DrawShape(DrawDot); } else { Painter = new DrawShape(DrawLine); } }
public CircuitEditor() { DrawingArea = new DrawingArea(); Offset = DisplayOffset = new Vector2d(0, 0); DrawingArea.Drawn += CircuitEditor_Drawn; DrawingArea.AddEvents((int)EventMask.PointerMotionMask); DrawingArea.AddEvents((int)EventMask.ScrollMask); DragGesture = new GestureDrag(DrawingArea); // Sets middle click as the pan button. // This should be configurable later! DragGesture.Button = 2; DragGesture.DragBegin += DragGesture_DragBegin; DragGesture.DragEnd += DragGesture_DragEnd; DragGesture.DragUpdate += DragGesture_DragUpdate; DragGestureCreate = new GestureDrag(DrawingArea); // Sets middle click as the wire creation button. // This should be configurable later! DragGestureCreate.Button = 1; DragGestureCreate.DragBegin += DragGestureCreate_DragBegin; DragGestureCreate.DragUpdate += DragGestureCreate_DragUpdate; DragGestureCreate.DragEnd += DragGestureCreate_DragEnd; DrawingArea.ScrollEvent += CircuitEditor_ScrollEvent; DrawingArea.QueryTooltip += CircuitEditor_QueryTooltip; DrawingArea.HasTooltip = true; DrawingArea.CanFocus = true; DrawingArea.FocusOnClick = true; DrawingArea.AddEvents((int)EventMask.KeyPressMask); DrawingArea.KeyPressEvent += DrawingArea_KeyPressEvent; // So that we can grab focus. Without focus we won't get any KeyPressEvents... // FIXME: We want to figure out how to do this in a good way where the user doesn't really // need to know where the current focus is for stuff like ctrl+z to work. DrawingArea.ParentSet += DrawingArea_ParentSet; DrawingArea.ButtonPressEvent += DrawingArea_ButtonPressEvent; var powered = new Wire[] { new Wire(new Vector2i(3, 3), 10, Direction.Vertical), new Wire(new Vector2i(3, 13), 10, Direction.Horizontal), new Wire(new Vector2i(0, 3), 3, Direction.Horizontal), new Wire(new Vector2i(3, 0), 3, Direction.Vertical), new Wire(new Vector2i(0, 13), 3, Direction.Horizontal), }; var unpowered = new Wire[] { new Wire(new Vector2i(13, 12), -9, Direction.Vertical), new Wire(new Vector2i(4, 3), 9, Direction.Horizontal), new Wire(new Vector2i(13, 3), 4, Direction.Horizontal), }; Wires = new Wires( powered, unpowered, // For wires to connect their start/end point must be at the same location // A wire that start/ends in the middle of another wires doesn't connect // (We might want to change that but it becomes more complicated then...) Wires.FindConnectionPoints(powered).ToArray(), Wires.FindConnectionPoints(unpowered).ToArray()); Gates = new Gates(/*new AndGate[] * { * new AndGate(new Vector2i(2, 2), Orientation.South), * new AndGate(new Vector2i(3, 7), Orientation.East), * new AndGate(new Vector2i(3, 10), Orientation.West), * new AndGate(new Vector2i(5, 3), Orientation.North), * }*/); Labels = new TextLabels(new TextLabel[] { new TextLabel(new Vector2d(0, 0), "This is some cool text.", 14), new TextLabel(new Vector2d(40, 10), "Even more cool text :O", 24), new TextLabel(new Vector2d(40, 40), "Woahhh :OOOoooO", 72), }); }
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 }; }
public GridView() { CanFocus = true; WidgetFlags |= WidgetFlags.NoWindow; selection = new GridSelection(this); orientation = Orientation.Vertical; StyleSet += new StyleSetHandler(OnStyleSet); StateChanged += new StateChangedHandler(OnStateChanged); FocusInEvent += new FocusInEventHandler(OnFocusInEvent); FocusOutEvent += new FocusOutEventHandler(OnFocusOutEvent); ButtonPressEvent += new ButtonPressEventHandler(OnButtonPressEvent); KeyPressEvent += new KeyPressEventHandler(OnKeyPressEvent); selection.Changed += new EventHandler(OnSelectionChanged); cda = new DrawingArea(); cda.ExposeEvent += new ExposeEventHandler(OnCDAExposeEvent); cda.AddEvents((int)EventMask.PointerMotionMask); cda.MotionNotifyEvent += new MotionNotifyEventHandler(OnYHeaderMotionNotifyEvent); cda.AddEvents((int)EventMask.ButtonPressMask); cda.ButtonPressEvent += new ButtonPressEventHandler(OnYHeaderButtonPressEvent); cda.AddEvents((int)EventMask.ButtonReleaseMask); cda.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnYHeaderButtonReleaseEvent); cda.AddEvents((int)EventMask.ScrollMask); Add(cda); tda = new DrawingArea(); tda.ExposeEvent += new ExposeEventHandler(OnTDAExposeEvent); tda.AddEvents((int)EventMask.PointerMotionMask); tda.MotionNotifyEvent += new MotionNotifyEventHandler(OnYHeaderMotionNotifyEvent); tda.AddEvents((int)EventMask.ButtonPressMask); tda.ButtonPressEvent += new ButtonPressEventHandler(OnYHeaderButtonPressEvent); tda.AddEvents((int)EventMask.ButtonReleaseMask); tda.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnYHeaderButtonReleaseEvent); tda.AddEvents((int)EventMask.ScrollMask); lda = new DrawingArea(); lda.ExposeEvent += new ExposeEventHandler(OnLDAExposeEvent); lda.AddEvents((int)EventMask.ScrollMask); lda.ButtonPressEvent += new ButtonPressEventHandler(OnLDAButtonPressEvent); fvp = new Viewport(); fvp.ShadowType = ShadowType.None; fda = new DrawingArea(); fda.StyleSet += new StyleSetHandler(OnFDAStyleSet); fda.Realized += new EventHandler(OnFDARealized); fda.ExposeEvent += new ExposeEventHandler(OnFDAExposeEvent); fda.AddEvents((int)EventMask.ButtonPressMask); fda.ButtonPressEvent += new ButtonPressEventHandler(OnFDAButtonPressEvent); fda.AddEvents((int)EventMask.ScrollMask); fvp.Add(fda); Add(fvp); tvp = new Viewport(fvp.Hadjustment, null); tvp.ShadowType = ShadowType.None; tvp.Add(tda); Add(tvp); lvp = new Viewport(null, fvp.Vadjustment); lvp.ShadowType = ShadowType.None; lvp.Add(lda); Add(lvp); hbar = new HScrollbar(fvp.Hadjustment); new LinkedScrollbar(hbar, tda, fda); Add(hbar); vbar = new VScrollbar(fvp.Vadjustment); new LinkedScrollbar(vbar, lda, fda); Add(vbar); }
public CircuitEditor() { DrawingArea = new DrawingArea(); Offset = DisplayOffset = new Vector2d(0, 0); DrawingArea.Drawn += CircuitEditor_Drawn; DrawingArea.AddEvents((int)EventMask.PointerMotionMask); DrawingArea.AddEvents((int)EventMask.ScrollMask); DragGesture = new GestureDrag(DrawingArea); // Sets middle click as the pan button. // This should be configurable later! DragGesture.Button = 2; DragGesture.DragBegin += DragGesture_DragBegin; DragGesture.DragEnd += DragGesture_DragEnd; DragGesture.DragUpdate += DragGesture_DragUpdate; DragGestureCreate = new GestureDrag(DrawingArea); // Sets middle click as the wire creation button. // This should be configurable later! DragGestureCreate.Button = 1; DragGestureCreate.DragBegin += DragGestureCreate_DragBegin; DragGestureCreate.DragUpdate += DragGestureCreate_DragUpdate; DragGestureCreate.DragEnd += DragGestureCreate_DragEnd; DrawingArea.MotionNotifyEvent += DrawingArea_MotionNotifyEvent; DrawingArea.ScrollEvent += CircuitEditor_ScrollEvent; DrawingArea.QueryTooltip += CircuitEditor_QueryTooltip; DrawingArea.HasTooltip = true; DrawingArea.CanFocus = true; DrawingArea.FocusOnClick = true; DrawingArea.AddEvents((int)EventMask.KeyPressMask); DrawingArea.KeyPressEvent += DrawingArea_KeyPressEvent; // So that we can grab focus. Without focus we won't get any KeyPressEvents... // FIXME: We want to figure out how to do this in a good way where the user doesn't really // need to know where the current focus is for stuff like ctrl+z to work. DrawingArea.ParentSet += DrawingArea_ParentSet; DrawingArea.ButtonPressEvent += DrawingArea_ButtonPressEvent; var wiresArr = new Wire[] { /*new Wire(new Vector2i(3, 3), 10, Direction.Vertical), * new Wire(new Vector2i(3, 13), 10, Direction.Horizontal), * new Wire(new Vector2i(0, 3), 3, Direction.Horizontal), * new Wire(new Vector2i(3, 0), 3, Direction.Vertical), * new Wire(new Vector2i(0, 13), 3, Direction.Horizontal), * new Wire(new Vector2i(13, 12), -9, Direction.Vertical), * new Wire(new Vector2i(4, 3), 9, Direction.Horizontal), * new Wire(new Vector2i(13, 3), 4, Direction.Horizontal),*/ }; var gates = new Gates(); var wires = new Wires(gates, wiresArr); var labels = new TextLabels(new TextLabel[] { new TextLabel(new Vector2d(0, 0), "This is some cool text.", 14), new TextLabel(new Vector2d(40, 10), "Even more cool text :O", 24), new TextLabel(new Vector2d(40, 40), "Woahhh :OOOoooO", 72), }); Scene = new Scene(wires, gates, labels); }