/// <summary> /// Disposes the unmanaged resources. /// This method is intended to be overriden. /// </summary> protected virtual void DisposeUnmanagedResources () { if (!Owned || DisposeUnmanagedFunc == null) return; FinalizerInfo info = new FinalizerInfo (DisposeUnmanagedFunc, Handle); Timeout.Add (50, new TimeoutHandler (info.Handler)); }
/// <summary> /// Triggered on the animation loop. /// </summary> private bool OnTick() { // Render the pane if (currentPane != null) { currentPane.Update(area); } // Handle the tick updating tickCount++; if (tickCount % 100 == 0) { double diff = (DateTime.UtcNow.Ticks - start) / 10000000.0; double efps = exposeCount / diff; double tfps = tickCount / diff; Demo.Statusbar.Push( 0, String.Format( "FPS: Exposed {0:N1} FPS ({3:N1}%), " + "Ticks {1:N1} FPS ({4:N1}%), " + "Maximum {2:N0} FPS", efps, tfps, DesiredFps, efps * 100 / DesiredFps, tfps * 100 / DesiredFps)); start = DateTime.UtcNow.Ticks; exposeCount = tickCount = 0; } // Re-request the animation Timeout.Add(1000 / DesiredFps, OnTick); return(false); }
/// <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); }
/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { // Bind any unhandled exceptions in the main thread so that they are logged. AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; // Set correct working directory for compatibility with double-clicking Directory.SetCurrentDirectory(DirectoryHelpers.GetLocalLauncherDirectory()); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Environment.SetEnvironmentVariable("GTK_EXE_PREFIX", Directory.GetCurrentDirectory()); Environment.SetEnvironmentVariable("GTK_DATA_PREFIX", Directory.GetCurrentDirectory()); Environment.SetEnvironmentVariable("GSETTINGS_SCHEMA_DIR", "share\\glib-2.0\\schemas\\"); } Log.Info($"\n\n\n"); Log.Info($"----------------------------------------------------------------------------"); Log.Info($"Launching Youcanevent launcher {System.DateTime.Now}"); Log.Info($"Launchpad v{LocalVersionService.GetLocalLauncherVersion()} starting..."); var systemBitness = Environment.Is64BitOperatingSystem ? "x64" : "x86"; var processBitness = Environment.Is64BitProcess ? "64-bit" : "32-bit"; Log.Info($"Current platform: {PlatformHelpers.GetCurrentPlatform()} ({systemBitness} platform, {processBitness} process)"); Log.Info("Initializing UI..."); // Bind any unhandled exceptions in the GTK UI so that they are logged. ExceptionManager.UnhandledException += OnGLibUnhandledException; // Run the GTK UI Gtk.Application.Init(); var win = MainWindow.Create(); win.Show(); Timeout.Add ( 50, () => { Task.Factory.StartNew ( () => win.InitializeAsync(), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.FromCurrentSynchronizationContext() ); return(false); } ); Gtk.Application.Run(); }
public void QueueUnref() { lock (PendingDestroys) { PendingDestroys.Add(this); if (!idle_queued) { Timeout.Add(50, new TimeoutHandler(PerformQueuedUnrefs)); idle_queued = true; } } }
public void QueueGCHandleFree() { lock (PendingGCHandleFrees) { PendingGCHandleFrees.Add(gch); if (!gc_idle_queued) { Timeout.Add(50, new TimeoutHandler(PerformGCHandleFrees)); gc_idle_queued = true; } } }
/// <summary> /// Constructs the pane with all the sprites. /// </summary> public DemoSpriteMoving() { // Create the basics sprites = new SpriteList(); viewport = new SpriteViewport(sprites); viewport.BackgroundColor = new Color(0, 0, 50); // Load in the static green sphere IDrawable drawable = DemoSprites.TilesetFactory.Create("red-sphere"); DrawableSprite sprite1 = new DrawableSprite(drawable); sprite = new MovingSprite(sprite1); sprite.StoppedMoving += OnStoppedMoving; sprite.Height = sprite.Width = 64; sprite.X = sprite.Y = 10; sprites.Add(sprite); // Create the target drawable = DemoSprites.TilesetFactory.Create("green-sphere"); target = new DrawableSprite(drawable); target.Height = target.Width = 32; sprites.Add(target); // Load in the static green sphere drawable = DemoSprites.TilesetFactory.Create("red-sphere2"); DrawableSprite sprite2a = new DrawableSprite(drawable); sprite2 = new MovingSprite(sprite2a); sprite2.Height = sprite2.Width = 64; sprite2.X = sprite2.Y = 10; sprites.Add(sprite2); // Create the target drawable = DemoSprites.TilesetFactory.Create("green-sphere"); target2 = new DrawableSprite(drawable); target2.Height = target2.Width = 32; sprites.Add(target2); sprite2.DesiredX = Entropy.Next(0, viewport.Width - sprite.Width); sprite2.DesiredY = Entropy.Next(0, viewport.Height - sprite.Height); target2.X = sprite2.DesiredX + 16; target2.Y = sprite2.DesiredY + 16; // Start our timer Timeout.Add(1000, OnNewLocation2); }
/// <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); }
void Dispose(bool disposing) { if (Handle == IntPtr.Zero) { return; } lock (lockObject) { PendingFrees.Add(handle); if (!idle_queued) { Timeout.Add(50, new TimeoutHandler(PerformFrees)); idle_queued = true; } } handle = IntPtr.Zero; }
private static async Task Main() { // Bind any unhandled exceptions in the main thread so that they are logged. AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; log4net.Config.XmlConfigurator.Configure(); Log.Info("----------------"); Log.Info($"Launchpad v{LocalVersionService.GetLocalLauncherVersion()} starting..."); Log.Info($"Current platform: {PlatformHelpers.GetCurrentPlatform()} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})"); // Set correct working directory for compatibility with double-clicking Directory.SetCurrentDirectory(DirectoryHelpers.GetLocalLauncherDirectory()); Log.Info("Initializing UI..."); // Bind any unhandled exceptions in the GTK UI so that they are logged. ExceptionManager.UnhandledException += OnGLibUnhandledException; // Run the GTK UI Gtk.Application.Init(); SynchronizationContext.SetSynchronizationContext(new GLibSynchronizationContext()); var win = new MainWindow(); win.Show(); Timeout.Add ( 50, () => { win.InitializeAsync(); return(false); } ); Gtk.Application.Run(); }
/// <summary> /// Triggers a new location 500 ms after it stops moving. /// </summary> private void OnStoppedMoving( object sender, EventArgs args) { Timeout.Add(500, OnNewLocation); }
public static uint AddSeconds(this Timeout timeout, uint interval, TimeoutHandler hndlr) { return(Timeout.Add(1000 * interval, hndlr)); }