PageRenderTime 23ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/ExperimentalProjection/Demo/frmMain.vb

#
Visual Basic | 87 lines | 68 code | 18 blank | 1 comment | 0 complexity | ae56e391cec89cd44ef62193d2cf1f99 MD5 | raw file
 1Public Class frmMain
 2
 3    Private _Projector As BaseProjector = Nothing
 4
 5    Private Sub tmrMain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMain.Tick
 6        If _Projector IsNot Nothing Then _Projector.RenderFrame()
 7    End Sub
 8
 9    Private Sub btnFadeOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFadeOut.Click
10
11        If _Projector IsNot Nothing Then
12            _Projector.HideProjectlet("Projectlet1", FadeEffect.FadeOut, TimeSpan.FromMilliseconds(1000))
13            _Projector.HideProjectlet("Projectlet2", FadeEffect.FadeOut, TimeSpan.FromMilliseconds(333))
14            _Projector.HideProjectlet("Projectlet3", FadeEffect.FadeOut, TimeSpan.FromMilliseconds(1000))
15        End If
16
17    End Sub
18
19    Private Sub btnFadeIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFadeIn.Click
20
21        If _Projector IsNot Nothing Then
22            _Projector.ShowProjectlet("Projectlet1", FadeEffect.FadeIn, TimeSpan.FromMilliseconds(1000))
23            _Projector.ShowProjectlet("Projectlet2", FadeEffect.FadeIn, TimeSpan.FromMilliseconds(333))
24            _Projector.ShowProjectlet("Projectlet3", FadeEffect.FadeIn, TimeSpan.FromMilliseconds(1000))
25        End If
26
27    End Sub
28
29    Private Sub ProjectionTypeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optGdi.CheckedChanged, optWpf.CheckedChanged
30
31        pnlGdiProjection.Visible = optGdi.Checked
32        pnlWpfProjection.Visible = optWpf.Checked
33        RecreateProjector()
34
35    End Sub
36
37    Private Sub RecreateProjector()
38
39        _Projector = Nothing
40        If optGdi.Checked Then
41            _Projector = ProjectorFactory.CreateGdiProjector(pnlGdiProjection)
42        Else
43            Dim ProjectionControl As WpfProjectionControl = pnlWpfProjection.Child
44            Dim GridControl As System.Windows.Controls.Grid = ProjectionControl.MainGrid
45            _Projector = ProjectorFactory.CreateWpfProjector(GridControl)
46        End If
47
48        ' TODO: Font styles
49        _Projector.AddProjectlet("Projectlet1", _
50                                 New AgnosticRectangle(0, 0, 1, 1), _
51                                 "Verdana",
52                                 AgnosticFontStyle.Italic, _
53                                 New AgnosticColour(0, 0, 255), _
54                                 0.02, _
55                                 New AgnosticColour(255, 255, 255), _
56                                 TextEffect.None, _
57                                 TextAlignment.TopLeft, _
58                                 "Song Title Goes Here")
59
60        _Projector.AddProjectlet("Projectlet2", _
61                                 New AgnosticRectangle(0, 0, 1, 1), _
62                                 "Arial", _
63                                 AgnosticFontStyle.Bold, _
64                                 New AgnosticColour(0, 0, 255), _
65                                 0.05, _
66                                 New AgnosticColour(255, 255, 255), _
67                                 TextEffect.OutlineAndShadow, _
68                                 TextAlignment.MiddleMiddle, _
69                                 "Hello World! Verse Line 1" + Environment.NewLine + _
70                                 "Hello World! Verse Line 2" + Environment.NewLine + _
71                                 "Hello World! Verse Line 3")
72
73        _Projector.AddProjectlet("Projectlet3", _
74                                 New AgnosticRectangle(0, 0, 1, 1), _
75                                 "Times New Roman", _
76                                 AgnosticFontStyle.Underline, _
77                                 New AgnosticColour(0, 0, 255), _
78                                 0.02, _
79                                 New AgnosticColour(255, 255, 255), _
80                                 TextEffect.Shadow, _
81                                 TextAlignment.BottomLeft, _
82                                 "Copyright Text Line 1" + Environment.NewLine + _
83                                 "Copyright Text Line 2")
84
85    End Sub
86
87End Class