C# Class Axiom.Samples.SampleContext

Base class responsible for setting up a common context for samples. May be subclassed for specific sample types (not specific samples). Allows one sample to run at a time, while maintaining a sample queue.
Inheritance: IWindowEventListener, SharpInputSystem.IKeyboardListener, SharpInputSystem.IMouseListener, IDisposable
Datei anzeigen Open project: WolfgangSt/axiom

Protected Properties

Property Type Description
ConfigurationManager IConfigurationManager
InputManager SharpInputSystem.InputManager
IsLastRun bool
IsSamplePaused bool
Keyboard SharpInputSystem.Keyboard
LastSample Sample
LastSampleState NameValuePairList
Mouse SharpInputSystem.Mouse
NextRenderer String
Root Axiom.Core.Root

Public Methods

Method Description
Dispose ( ) : void
FrameEnded ( object sender, FrameEventArgs evt ) : void

Processes frame ended events.

FrameRenderingQueued ( object sender, FrameEventArgs evt ) : void

Processes rendering queued events.

FrameStarted ( object sender, FrameEventArgs evt ) : void

Processes frame started events.

Go ( ) : void

This function encapsulates the entire lifetime of the context.

Go ( Sample initialSample ) : void

This function encapsulates the entire lifetime of the context.

KeyPressed ( SharpInputSystem evt ) : bool
KeyReleased ( SharpInputSystem evt ) : bool
MouseMoved ( SharpInputSystem evt ) : bool
MousePressed ( SharpInputSystem evt, SharpInputSystem id ) : bool
MouseReleased ( SharpInputSystem evt, SharpInputSystem id ) : bool
PauseCurrentSample ( ) : void

Pauses the current running sample

RunSample ( Sample s ) : void

Quits the current sample and starts a new one.

SampleContext ( IConfigurationManager cfgManager ) : System

Creates a new instance of the type SampleContext

UnpauseCurrentSample ( ) : void

Unpauses the current sample

WindowClosed ( Axiom.Graphics.RenderWindow rw ) : void
WindowClosing ( Axiom.Graphics.RenderWindow rw ) : bool
WindowFocusChange ( Axiom.Graphics.RenderWindow rw ) : void
WindowMoved ( Axiom.Graphics.RenderWindow rw ) : void
WindowResized ( Axiom.Graphics.RenderWindow rw ) : void

Processes window size change event. Adjusts mouse's region to match that of the window. You could also override this method to prevent resizing.

Protected Methods

Method Description
CaptureInputDevices ( ) : void

Captures input device states.

CreateInputDevices ( ) : void

Creates the individual input devices. I only create a keyboard and mouse here because they are the most common, but you can override this method for other modes and devices.

CreateRoot ( ) : void

Creates the Axiom root.

CreateWindow ( ) : void

Creates the render window to be used for this context. I use an auto-created window here, but you can also create an external window if you wish. Just don't forget to initialize the root.

LoadResources ( ) : void

Loads context-wide resource groups. I chose here to simply initialise all groups, but you can fully load specific ones if you wish.

LocateResources ( ) : void

Finds context-wide resource groups. I load paths from a config file here, but you can choose your resource locations however you want.

Log ( string msg ) : void

Logs a message to the default logfile.

OneTimeConfig ( ) : bool

Configures the startup settings for Axiom. It will first load the settings from a configuration file, then open a dialog for any further configuration.

Reconfigure ( String renderer, NameValuePairList options ) : void

Reconfigures the context. Attempts to preserve the current sample state.

RecoverLastSample ( ) : void

Recovers the last sample after a reset. You can override in the case that the last sample is destroyed in the process of resetting, and you have to recover it through another means.

Setup ( ) : void

Sets up the context after configuration.

SetupInput ( ) : void

Sets up SIS input.

Shutdown ( ) : void

Cleans up and shuts down the context.

ShutdownInput ( ) : void

Destroys SIS input devices and the input manager.

Method Details

CaptureInputDevices() protected method

Captures input device states.
protected CaptureInputDevices ( ) : void
return void

CreateInputDevices() protected method

Creates the individual input devices. I only create a keyboard and mouse here because they are the most common, but you can override this method for other modes and devices.
protected CreateInputDevices ( ) : void
return void

CreateRoot() protected method

Creates the Axiom root.
protected CreateRoot ( ) : void
return void

CreateWindow() protected method

Creates the render window to be used for this context. I use an auto-created window here, but you can also create an external window if you wish. Just don't forget to initialize the root.
protected CreateWindow ( ) : void
return void

Dispose() public method

public Dispose ( ) : void
return void

FrameEnded() public method

Processes frame ended events.
public FrameEnded ( object sender, FrameEventArgs evt ) : void
sender object
evt FrameEventArgs
return void

FrameRenderingQueued() public method

Processes rendering queued events.
public FrameRenderingQueued ( object sender, FrameEventArgs evt ) : void
sender object
evt FrameEventArgs
return void

FrameStarted() public method

Processes frame started events.
public FrameStarted ( object sender, FrameEventArgs evt ) : void
sender object
evt FrameEventArgs
return void

Go() public method

This function encapsulates the entire lifetime of the context.
public Go ( ) : void
return void

Go() public method

This function encapsulates the entire lifetime of the context.
public Go ( Sample initialSample ) : void
initialSample Sample
return void

KeyPressed() public method

public KeyPressed ( SharpInputSystem evt ) : bool
evt SharpInputSystem
return bool

KeyReleased() public method

public KeyReleased ( SharpInputSystem evt ) : bool
evt SharpInputSystem
return bool

LoadResources() protected method

Loads context-wide resource groups. I chose here to simply initialise all groups, but you can fully load specific ones if you wish.
protected LoadResources ( ) : void
return void

LocateResources() protected method

Finds context-wide resource groups. I load paths from a config file here, but you can choose your resource locations however you want.
protected LocateResources ( ) : void
return void

Log() protected method

Logs a message to the default logfile.
protected Log ( string msg ) : void
msg string
return void

MouseMoved() public method

public MouseMoved ( SharpInputSystem evt ) : bool
evt SharpInputSystem
return bool

MousePressed() public method

public MousePressed ( SharpInputSystem evt, SharpInputSystem id ) : bool
evt SharpInputSystem
id SharpInputSystem
return bool

MouseReleased() public method

public MouseReleased ( SharpInputSystem evt, SharpInputSystem id ) : bool
evt SharpInputSystem
id SharpInputSystem
return bool

OneTimeConfig() protected method

Configures the startup settings for Axiom. It will first load the settings from a configuration file, then open a dialog for any further configuration.
protected OneTimeConfig ( ) : bool
return bool

PauseCurrentSample() public method

Pauses the current running sample
public PauseCurrentSample ( ) : void
return void

Reconfigure() protected method

Reconfigures the context. Attempts to preserve the current sample state.
protected Reconfigure ( String renderer, NameValuePairList options ) : void
renderer String
options NameValuePairList
return void

RecoverLastSample() protected method

Recovers the last sample after a reset. You can override in the case that the last sample is destroyed in the process of resetting, and you have to recover it through another means.
protected RecoverLastSample ( ) : void
return void

RunSample() public method

Quits the current sample and starts a new one.
public RunSample ( Sample s ) : void
s Sample
return void

SampleContext() public method

Creates a new instance of the type SampleContext
public SampleContext ( IConfigurationManager cfgManager ) : System
cfgManager IConfigurationManager
return System

Setup() protected method

Sets up the context after configuration.
protected Setup ( ) : void
return void

SetupInput() protected method

Sets up SIS input.
protected SetupInput ( ) : void
return void

Shutdown() protected method

Cleans up and shuts down the context.
protected Shutdown ( ) : void
return void

ShutdownInput() protected method

Destroys SIS input devices and the input manager.
protected ShutdownInput ( ) : void
return void

UnpauseCurrentSample() public method

Unpauses the current sample
public UnpauseCurrentSample ( ) : void
return void

WindowClosed() public method

public WindowClosed ( Axiom.Graphics.RenderWindow rw ) : void
rw Axiom.Graphics.RenderWindow
return void

WindowClosing() public method

public WindowClosing ( Axiom.Graphics.RenderWindow rw ) : bool
rw Axiom.Graphics.RenderWindow
return bool

WindowFocusChange() public method

public WindowFocusChange ( Axiom.Graphics.RenderWindow rw ) : void
rw Axiom.Graphics.RenderWindow
return void

WindowMoved() public method

public WindowMoved ( Axiom.Graphics.RenderWindow rw ) : void
rw Axiom.Graphics.RenderWindow
return void

WindowResized() public method

Processes window size change event. Adjusts mouse's region to match that of the window. You could also override this method to prevent resizing.
public WindowResized ( Axiom.Graphics.RenderWindow rw ) : void
rw Axiom.Graphics.RenderWindow
return void

Property Details

ConfigurationManager protected_oe property

Configuration Manager
protected IConfigurationManager ConfigurationManager
return IConfigurationManager

InputManager protected_oe property

SharpInputSystem Input Manager
protected InputManager,SharpInputSystem InputManager
return SharpInputSystem.InputManager

IsLastRun protected_oe property

Whether or not this is the final run
protected bool IsLastRun
return bool

IsSamplePaused protected_oe property

protected bool IsSamplePaused
return bool

Keyboard protected_oe property

Keyboard Device
protected Keyboard,SharpInputSystem Keyboard
return SharpInputSystem.Keyboard

LastSample protected_oe property

last sample run before reconfiguration
protected Sample LastSample
return Sample

LastSampleState protected_oe property

state of last sample
protected NameValuePairList LastSampleState
return NameValuePairList

Mouse protected_oe property

Mouse Device
protected Mouse,SharpInputSystem Mouse
return SharpInputSystem.Mouse

NextRenderer protected_oe property

Name of renderer used for next run
protected String NextRenderer
return String

Root protected_oe property

Axiom root
protected Root,Axiom.Core Root
return Axiom.Core.Root