I am trying to figure out how to leave the class initialized but to return the code back to the calling function. I am calling a Drawing.Graphics window from a WinForms form.
I tried a few of these 1 at a time but they did not help:
I tried a few of these 1 at a time but they did not help:
C#:
_window.Dispose();
System.Windows.Forms.Application.ExitThread();
System.Environment.Exit(Convert.ToInt32(unlockedPopup));
return -1;
#region Assembly GameOverlay, Version=4.3.0.0, Culture=neutral, PublicKeyToken=null
// C:\Users\Jeff\Documents\Visual Studio 2010\Projects\StudyxMain\StudyxMain\packages\GameOverlay.Net.4.3.0\lib\net45\GameOverlay.dll
#endregion
using System;
using GameOverlay.Drawing;
namespace GameOverlay.Windows
{
//
// Summary:
// Represents an OverlayWindow which is used to draw at any given frame rate.
public class GraphicsWindow : OverlayWindow
{
//
// Summary:
// Initializes a new GraphicsWindow.
//
// Parameters:
// device:
// Optionally specify a Graphics device to use.
public GraphicsWindow(Graphics device = null);
//
// Summary:
// Initializes a new GraphicsWindow with the specified window position and size.
//
// Parameters:
// x:
// The window position on the X-Axis.
//
// y:
// The window position on the Y-Axis.
//
// width:
// The width of the window.
//
// height:
// The height of the window.
//
// device:
// Optionally specify a Graphics device to use.
public GraphicsWindow(int x, int y, int width, int height, Graphics device = null);
//
// Summary:
// Allows an object to try to free resources and perform other cleanup operations
// before it is reclaimed by garbage collection.
~GraphicsWindow();
//
// Summary:
// Gets or sets a Boolean which determines whether this instance is running.
public bool IsRunning { get; set; }
//
// Summary:
// Gets or sets a Boolean which determines whether this instance is paused.
public bool IsPaused { get; set; }
//
// Summary:
// Gets or sets the used Graphics surface.
public Graphics Graphics { get; }
//
// Summary:
// Gets or sets the frames per second (frame rate) at which this instance invokes
// its DrawGraphics event.
public int FPS { get; set; }
//
// Summary:
// Fires when you should free any resources used for drawing with this instance.
public event EventHandler<DestroyGraphicsEventArgs> DestroyGraphics;
//
// Summary:
// Fires when a new Scene / frame needs to be rendered.
public event EventHandler<DrawGraphicsEventArgs> DrawGraphics;
//
// Summary:
// Fires when you should allocate any resources you use to draw using this instance.
public event EventHandler<SetupGraphicsEventArgs> SetupGraphics;
//
public override void Create();
//
public override void Join();
//
// Summary:
// Pauses the graphics thread.
public void Pause();
//
// Summary:
// Resumes the graphics thread.
public void Unpause();
//
// Summary:
// Releases all resources used by this GraphicsWindow.
//
// Parameters:
// disposing:
// A Boolean value indicating whether this is called from the destructor.
protected override void Dispose(bool disposing);
//
// Summary:
// Gets called when the graphics thread destorys the Graphics surface.
//
// Parameters:
// graphics:
// A Graphics surface.
protected virtual void OnDestroyGraphics(Graphics graphics);
//
// Summary:
// Gets called when the graphics thread needs to render a new Scene / frame.
//
// Parameters:
// frameCount:
// The number of the currently rendered frame. Starting at 1.
//
// frameTime:
// The current time in milliseconds.
//
// deltaTime:
// The elapsed time in milliseconds since the last frame.
protected virtual void OnDrawGraphics(int frameCount, long frameTime, long deltaTime);
//
// Summary:
// Gets called when the graphics thread setups the Graphics surface.
//
// Parameters:
// graphics:
// A Graphics surface.
protected virtual void OnSetupGraphics(Graphics graphics);
//
protected override void OnSizeChanged(int width, int height);
//
protected override void OnVisibilityChanged(bool isVisible);
}
}
using System;
using System.Collections.Generic;
using System.Text;
using GameOverlay.Drawing;
using GameOverlay.Windows;
namespace StudyCSharp
{
public class OverlayQuestion : IDisposable
{
private readonly GraphicsWindow _window;
public OverlayQuestion()
{
StudyX.Module1.initializeModule1();
_brushes = new Dictionary<string, SolidBrush>();
_fonts = new Dictionary<string, Font>();
_images = new Dictionary<string, Image>();
generateStudyQuestion();
var gfx = new Graphics()
{
MeasureFPS = true,
PerPrimitiveAntiAliasing = true,
TextAntiAliasing = true
};
int _ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
int _ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
_window = new GraphicsWindow(0, 0, _ScreenWidth, _ScreenHeight, gfx)
{
FPS = 60,
IsTopmost = true,
IsVisible = true
};
_window.DestroyGraphics += _window_DestroyGraphics;
_window.DrawGraphics += _window_DrawGraphics;
_window.SetupGraphics += _window_SetupGraphics;
}
}