-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualsWindow.xaml.cs
More file actions
79 lines (76 loc) · 3.7 KB
/
VisualsWindow.xaml.cs
File metadata and controls
79 lines (76 loc) · 3.7 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.ComponentModel;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace OverlayControl
{
/// <summary>
/// Window containing the visuals to be used for a stream overlay, including characters, moon styles and country flags.
/// </summary>
public partial class VisualsWindow : Window, IComponentConnector
{
/// <summary>
/// Constructor for the VisualsWindow class, containing the visuals to be used for a stream overlay, including characters, moon styles and country flags.
/// </summary>
/// <param name="cutIn01">Image representing player 1's character.</param>
/// <param name="moon01">Image representing player 1's moon style.</param>
/// <param name="cutIn02">Image representing player 2's character.</param>
/// <param name="moon02">Image representing player 1's moon style.</param>
/// <param name="flag01">Image representing player 1's country flag.</param>
/// <param name="flag02">Image representing player 2's country flag.</param>
public VisualsWindow(BitmapImage cutIn01, BitmapImage moon01, BitmapImage cutIn02, BitmapImage moon02, BitmapImage flag01, BitmapImage flag02)
{
InitializeComponent();
Height = 768.0;
Width = 1024.0;
imgCutIn1.Source = (ImageSource)cutIn01;
imgMoon1.Source = (ImageSource)moon01;
imgFlag1.Source = (ImageSource)flag01;
imgCutIn2.Source = (ImageSource)cutIn02;
imgMoon2.Source = (ImageSource)moon02;
imgFlag2.Source = (ImageSource)flag02;
}
/// <summary>
/// Updates the images shown in the VisualsWindow.
/// </summary>
/// <param name="cutIn01">Image representing player 1's character.</param>
/// <param name="moon01">Image representing player 1's moon style.</param>
/// <param name="cutIn02">Image representing player 2's character.</param>
/// <param name="moon02">Image representing player 1's moon style.</param>
/// <param name="flag01">Image representing player 1's country flag.</param>
/// <param name="flag02">Image representing player 2's country flag.</param>
/// <returns>Whether the operation was successful or not.</returns>
public bool ChangeSource(BitmapImage cutIn01, BitmapImage moon01, BitmapImage cutIn02, BitmapImage moon02, BitmapImage flag01, BitmapImage flag02)
{
try
{
imgCutIn1.Source = (ImageSource)cutIn01;
imgMoon1.Source = (ImageSource)moon01;
imgFlag1.Source = (ImageSource)flag01;
imgFlag1.Stretch = Stretch.Uniform;
imgFlag1.HorizontalAlignment = HorizontalAlignment.Center;
imgCutIn2.Source = (ImageSource)cutIn02;
imgMoon2.Source = (ImageSource)moon02;
imgFlag2.Source = (ImageSource)flag02;
imgFlag2.Stretch = Stretch.Uniform;
imgFlag2.HorizontalAlignment = HorizontalAlignment.Center;
return true;
}
catch
{
return false;
}
}
/// <summary>
/// Cancelable event fired when attempting to close the window containing the stream overlay visuals.
/// </summary>
/// <param name="sender">The control that was used to fire this event.</param>
/// <param name="e">Provides data for the cancelable event.</param>
private void wndVisuals_Closing(object sender, CancelEventArgs e)
{
// Cancel manual closing of this window
e.Cancel = true;
}
}
}