public static void Main(string[] args) { Gtk.Application.Init("test", ref args); Gtk.Window window = new Gtk.Window("Test"); Gtk.WindowGroup grp = new Gtk.WindowGroup(); grp.AddWindow(window); window.SetDefaultSize(400, 300); Plot.Widget area = new Plot.Widget(); d_graph = area.Graph; d_graph.AxisAspect = 1; d_graph.KeepAspect = true; window.Add(area); window.ShowAll(); window.DeleteEvent += delegate { Gtk.Application.Quit(); }; d_i = 0; Plot.Series.Point s1 = new Plot.Series.Point("test 1"); s1.Size = 5; s1.ShowLines = true; Plot.Series.Line s2 = new Plot.Series.Line("test 2"); d_graph.ShowRuler = true; d_graph.Add(s1); d_graph.Add(s2); List <Plot.Point <double> > d1 = new List <Plot.Point <double> >(); List <Plot.Point <double> > d2 = new List <Plot.Point <double> >(); int samplesize = 1000; //GLib.Timeout.Add(10, delegate { for (int i = 0; i <= samplesize; ++i) { d_i = i; double x = d_i++ / (double)samplesize; Plot.Point <double> pt1 = new Plot.Point <double>(x, Math.Sin(x * Math.PI * 2)); Plot.Point <double> pt2 = new Plot.Point <double>(x, Math.Cos(x * Math.PI * 2)); d1.Add(pt1); d2.Add(pt2); } s1.Data = d1; s2.Data = d2; Gtk.Application.Run(); }
public void DetachPlayer() { bool isPlaying = ViewModel.VideoPlayer.Playing; /* Pause the player here to prevent the sink drawing while the windows * are beeing changed */ ViewModel.VideoPlayer.Pause(); if (!detachedPlayer) { Log.Debug("Detaching player"); ExternalWindow playerWindow = new ExternalWindow(); this.playerWindow = playerWindow; playerWindow.Title = Constants.SOFTWARE_NAME; int player_width = playercapturer.Allocation.Width; int player_height = playercapturer.Allocation.Height; playerWindow.SetDefaultSize(player_width, player_height); playerWindow.DeleteEvent += (o, args) => DetachPlayer(); playerWindow.Show(); playercapturer.Reparent(playerWindow.Box); // Hack to reposition video window in widget for OSX playerWindow.Resize(player_width + 10, player_height); videowidgetsbox.Visible = false; playsSelection.ExpandTabs = true; } else { Log.Debug("Attaching player again"); videowidgetsbox.Visible = true; playercapturer.Reparent(this.videowidgetsbox); playerWindow.Destroy(); playsSelection.ExpandTabs = false; } if (isPlaying) { ViewModel.VideoPlayer.Play(); } detachedPlayer = !detachedPlayer; playercapturer.AttachPlayer(detachedPlayer); }
protected void OnButtonMapInWindowClicked(object sender, EventArgs e) { if (mapWindow == null) { toggleButtonHideAddresses.Sensitive = false; toggleButtonHideAddresses.Active = false; mapWindow = new Gtk.Window("Карта мониторинга автомобилей на маршруте"); mapWindow.SetDefaultSize(700, 600); mapWindow.DeleteEvent += MapWindow_DeleteEvent; vboxRight.Remove(gmapWidget); mapWindow.Add(gmapWidget); mapWindow.Show(); } else { toggleButtonHideAddresses.Sensitive = true; mapWindow.Remove(gmapWidget); vboxRight.PackEnd(gmapWidget, true, true, 1); gmapWidget.Show(); mapWindow.Destroy(); mapWindow = null; } }
void HandleBrowseExisting(object sender, System.EventArgs args) { #if GIO_2_16 if (listwindow == null) { listwindow = new Gtk.Window("Pending files to write"); listwindow.SetDefaultSize(400, 200); listwindow.DeleteEvent += delegate(object o, Gtk.DeleteEventArgs e) { (o as Gtk.Window).Destroy(); listwindow = null; }; Gtk.TextView view = new Gtk.TextView(); Gtk.TextBuffer buffer = view.Buffer; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); sw.Add(view); listwindow.Add(sw); } else { ((listwindow.Child as Gtk.ScrolledWindow).Child as Gtk.TextView).Buffer.Text = ""; } ListAll(((listwindow.Child as Gtk.ScrolledWindow).Child as Gtk.TextView).Buffer, dest); listwindow.ShowAll(); #else GnomeUtil.UrlShow(dest.ToString()); #endif }
public void Run() { Gtk.Application.Init(); ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkUIElementPointersSupport(o)); _window = new Gtk.Window("Uno Host"); _window.SetDefaultSize(1024, 800); _window.SetPosition(Gtk.WindowPosition.Center); _window.DeleteEvent += delegate { Gtk.Application.Quit(); }; Windows.UI.Core.CoreDispatcher.DispatchOverride = d => { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(false); } GLib.Idle.Add(delegate { Console.WriteLine("iteration"); try { d(); } catch (Exception e) { Console.WriteLine(e); } return(false); }); }; _window.Realized += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight)); }; _window.SizeAllocated += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height)); }; var area = new UnoDrawingArea(); _window.Add(area); /* avoids double invokes at window level */ area.AddEvents((int)( Gdk.EventMask.PointerMotionMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask )); _window.ShowAll(); WUX.Application.Start(_ => _appBuilder()); Gtk.Application.Run(); }
public void Run() { Gtk.Application.Init(); ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkUIElementPointersSupport(o)); ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o)); ApiExtensibility.Register(typeof(IApplicationExtension), o => new GtkApplicationExtension(o)); ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window)); _window = new Gtk.Window("Uno Host"); _window.SetDefaultSize(1024, 800); _window.SetPosition(Gtk.WindowPosition.Center); _window.DeleteEvent += delegate { Gtk.Application.Quit(); }; Windows.UI.Core.CoreDispatcher.DispatchOverride = d => { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(false); } GLib.Idle.Add(delegate { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace)) { this.Log().Trace($"Iteration"); } try { d(); } catch (Exception e) { Console.WriteLine(e); } return(false); }); }; _window.Realized += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight)); }; _window.SizeAllocated += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height)); }; _area = new UnoDrawingArea(); _window.Add(_area); /* avoids double invokes at window level */ _area.AddEvents((int)( Gdk.EventMask.PointerMotionMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask )); _window.ShowAll(); void CreateApp(ApplicationInitializationCallbackParams _) { var app = _appBuilder(); app.Host = this; } WUX.Application.Start(CreateApp, _args); UpdateWindowPropertiesFromPackage(); Gtk.Application.Run(); }
static void GlobalSetup () { if (initedGlobal || setupFail) return; initedGlobal = true; //FIXME: should we remove these when finalizing? try { ApplicationEvents.Quit += delegate (object sender, ApplicationQuitEventArgs e) { if (!IdeApp.Exit ()) e.UserCancelled = true; e.Handled = true; }; ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) { if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null) { IdeApp.Workbench.RootWindow.Deiconify (); IdeApp.Workbench.RootWindow.Show (); // This is a workaround to a GTK+ bug. The HasTopLevelFocus flag is not properly // set when the main window is restored. The workaround is to create and quickly // destroy a top level window. GTK+ then detects that the top level focus has // changed and properly sets HasTopLevelFocus. Gtk.Window ww = new Gtk.Window (""); ww.Decorated = false; ww.SetDefaultSize (0, 0); ww.Present (); IdeApp.Workbench.RootWindow.Present (); GLib.Timeout.Add (1, delegate { // Without this small delay, GTK+ crashes when destroying the window ww.Destroy (); return false; }); e.Handled = true; } }; ApplicationEvents.OpenDocuments += delegate (object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add (10, delegate { IdeApp.OpenFiles (e.Documents.Select (doc => new FileOpenInformation (doc.Key, doc.Value, 1, OpenDocumentOptions.Default))); return false; }); e.Handled = true; }; //if not running inside an app bundle, assume usual MD build layout and load the app icon FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly ().Location; if (!exePath.ToString ().Contains ("MonoDevelop.app")) { var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; var icons = mdSrcMain.Combine ("theme-icons", "Mac", "monodevelop.icns"); if (File.Exists (icons)) NSApplication.SharedApplication.ApplicationIconImage = new NSImage (icons); } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError ("Could not install app event handlers", ex); setupFail = true; } }
public void Run() { Gtk.Application.Init(); ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkCoreWindowExtension(o)); ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o)); ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o)); ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window)); _isDispatcherThread = true; _window = new Gtk.Window("Uno Host"); _window.SetDefaultSize(1024, 800); _window.SetPosition(Gtk.WindowPosition.Center); _window.DeleteEvent += delegate { Gtk.Application.Quit(); }; bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback) { Dispatch(() => callback()); return(true); } Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative; void Dispatch(Action d) { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(false); } GLib.Idle.Add(delegate { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace)) { this.Log().Trace($"Iteration"); } try { d(); } catch (Exception e) { Console.WriteLine(e); } return(false); }); } Windows.UI.Core.CoreDispatcher.DispatchOverride = Dispatch; Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => _isDispatcherThread; _window.Realized += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight)); }; _window.SizeAllocated += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height)); }; _area = new UnoDrawingArea(); _window.Add(_area); /* avoids double invokes at window level */ _area.AddEvents((int)GtkCoreWindowExtension.RequestedEvents); _window.ShowAll(); void CreateApp(ApplicationInitializationCallbackParams _) { var app = _appBuilder(); app.Host = this; } WUX.Application.Start(CreateApp, _args); UpdateWindowPropertiesFromPackage(); Gtk.Application.Run(); }