-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderingModule.cs
More file actions
64 lines (58 loc) · 2.34 KB
/
RenderingModule.cs
File metadata and controls
64 lines (58 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Drawing;
using System.Windows.Media;
using System.Windows.Threading;
namespace NITHtemplate.Modules
{
/// <summary>
/// The RenderingModule class is responsible for managing the rendering of graphics in the application.
/// It utilizes a DispatcherTimer to repeatedly trigger rendering operations at specified intervals.
/// </summary>
public class RenderingModule : IDisposable
{
/// <summary>
/// Initializes a new instance of the RenderingModule class.
/// </summary>
/// <param name="window">The main window instance where rendering will take place.</param>
public RenderingModule(MainWindow window)
{
Window = window;
DispatcherTimer = new DispatcherTimer();
DispatcherTimer.Interval = new TimeSpan(10000); // 10000 nanoseconds = one millisecond
DispatcherTimer.Tick += DispatcherUpdate;
}
private DispatcherTimer DispatcherTimer { get; set; }
private MainWindow Window { get; set; }
/// <summary>
/// Releases the resources used by the RenderingModule.
/// This stops the rendering timer.
/// </summary>
public void Dispose()
{
DispatcherTimer.Stop();
}
/// <summary>
/// Starts the rendering timer which will invoke the update method at regular intervals.
/// </summary>
public void StartRendering()
{
DispatcherTimer.Start();
}
/// <summary>
/// Stops the rendering timer to prevent further updates.
/// </summary>
public void StopRendering()
{
DispatcherTimer.Stop();
}
/// <summary>
/// This method is called every time the dispatcher timer is triggered to update graphics.
/// Place rendering instructions inside this method.
/// </summary>
private void DispatcherUpdate(object sender, EventArgs e)
{
Window.prbHeadMovement.Value = Rack.MappingModule.headPosYaw;
Window.rctLeftBlink.Fill = Rack.MappingModule.leftEyeIsBlinking ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
Window.rctRightBlink.Fill = Rack.MappingModule.rightEyeIsBlinking ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
}
}
}