Skip to content

MainWindow

Sasso edited this page Jan 30, 2021 · 3 revisions

Interaction logic for MainWindow.xaml

Constructor

This method is called when the program starts. It checks if the user has an ID assigned, if not it try to get a new ID from the database and assign it to the user. Then check if there are fonts to be installed and, if it is the case, installs them. Finally, initialise the GUI.


CloseWindow(System.Object,System.Windows.RoutedEventArgs)

Close the window and display any catched exception message in a popup window.


DisplayNextImage(System.Windows.Controls.Image)

Animation code for the image changing


DownloadAndInstall(sender, e)

Start download. When it finishes, start unzipping.

Name Description
sender System.Object
e System.Windows.RoutedEventArgs

InitializeComponent

InitializeComponent

InitPlayButton

Enable MainWindow.button, change its color and content and set MainWindow.LaunchGame(System.Object,System.Windows.RoutedEventArgs) as function to be called on click.


LaunchGame(sender, e)

Search for program executable and launch it.

Name Description
sender System.Object
e System.Windows.RoutedEventArgs

MoveWindow(System.Object,System.Windows.Input.MouseButtonEventArgs)

Make top Rectangle draggable


RemoveRoutedEventHandlers(element, routedEvent)

Removes all event handlers subscribed to the specified routed event from the specified element. Credit: https://stackoverflow.com/a/16392387/1149773

Name Description
element System.Windows.UIElement
The UI element on which the routed event is defined.
routedEvent System.Windows.RoutedEvent
The routed event for which to remove the event handlers.

SetBarIdle(idle)

Set ProgressBar.IsIndeterminate = idle

Name Description
idle System.Boolean
true for show indeterminate loading, false otherwise

Tick(System.Object,System.EventArgs)

Tick on the dispatchtimer called every 10 seconds. Used to update background Images.


ToggleOptions(sender, e)

Show/hide options windows. In addition hide notice window.

Name Description
sender System.Object
e System.Windows.RoutedEventArgs

Unzip(zipPath)

Unzip a file and show progress in MainWindow.BarGrid.

Name Description
zipPath System.String
Archive to uzip's full path.

UpdateBarProgress(value)

Updates the progress bar to the given value.

Name Description
value System.Double
The target value.

Window_Loaded(sender, e)

It is called when the GUI is loaded. It implements the main logic of the program.

Name Description
sender System.Object
e System.Windows.RoutedEventArgs