Skip to content
< All Topics

Scene

Experior.Core.Environment.Scene

Properties

bool Paused: The Paused property returns true when the model is Paused (Simulated time is not progressing), false otherwise.
bool Locked: The Locked property returns true if the Environment is in locked mode which implies that the model cannot be edited.

Events

event Event Cleared: The Cleared event is triggered when the workspace is cleared. This occurs when a model is closed (either by explicitly closing a model or starting a new model).
event Event Loaded: The Loaded event is triggered when a model is opened and completely loaded.
event Event Locking: The Locking event is triggered when locking the model.
event Event Pausing: The Pausing event is called when the model is being paused.
event Event Saved: The Saved event is called when the current model is saved.

Methods

Continue(): The Continue method resumes the running of the model.

Lock(): The Lock method locks the model.

Pause(): The Pause method pauses the running of the model.  

Reset(): The Reset method pauses the model and resets the clock to 0. It will also reset all assemblies of the model  

UnLock(): The Lock method unlocks the model so that it can be edited.

 

Example

Below is an example of an assembly that illustrates the usage of above described events/methods:

public ExampleEnvironment(AssemblyInfo info)
: base(info)
{
    Experior.Core.Environment.Scene.Loaded += Scene_Loaded;
    Experior.Core.Environment.Scene.Pausing += Scene_Pausing;
    Experior.Core.Environment.Scene.Saved += Scene_Saved;
    Experior.Core.Environment.Scene.Cleared += Scene_Cleared;
    Experior.Core.Environment.Scene.Locking += Scene_Locking;
}

void Scene_Locking()
{
    Experior.Core.Environment.Diagnostic.Message(this.Name, "Diagnostic message : Scene is locked");
}

void Scene_Cleared()
{
    Experior.Core.Environment.Diagnostic.Message(this.Name,"Diagnostic message : Scene is cleared");
}

void Scene_Saved()
{
    Experior.Core.Environment.Diagnostic.Message(this.Name, "This is a diagnostic message in blue to indicate the model is saved", Blue);
}

void Scene_Pausing()
{
    Experior.Core.Environment.Diagnostic.Message("This is a diagnostic message to indicate the model is paused");

    /// this will clear the Properties window
    Experior.Core.Environment.Properties.Clear();
}

void Scene_Loaded()
{
    // change the presentation level to WireFrame
    Experior.Core.Environment.Scene.PresentationLevel = Wireframe;

    // lock the model
    Experior.Core.Environment.Scene.Lock();

    // if custom assemblies contain references to other assemblies those
    // references can be re-established after the model has been
    // loaded again in a Scene_Loaded delegate
    // suppose we have two assemblies A and B both having
    // property LinkedAssembly that reference the other assembly.
    // when loading the model this relationship can only be completely
    // reestablished when the model is completely loaded
    // and we are sure that both assemblies exist.
    // (In the constructor of Assembly A we could not do this
    // yet because it is not garanteed that
    // Assembly B exists already. Or vice versa)
    // A.LinkedAssembly = B
    // B.LinkedAssembly = A
    Experior.Core.Environment.Diagnostic.Message("This is a sticky diagnostic message in Red", System.Drawing.Color.Red, STICKY);
}

public override void Reset()
{
    base.Reset();
    Experior.Core.Environment.Diagnostic.Message(this.Name, "Diagnostic message : assembly " + this.Name + " is reset");
}

public override void Dispose()
{
    base.Dispose();
    // unsubscribe to events when disposing
    Experior.Core.Environment.Scene.Loaded -= Scene_Loaded;
    Experior.Core.Environment.Scene.Pausing -= Scene_Pausing;
    Experior.Core.Environment.Scene.Saved -= Scene_Saved;
    Experior.Core.Environment.Scene.Cleared -= Scene_Cleared;
    Experior.Core.Environment.Scene.Locking -= Scene_Locking;
}
Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.