-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGanar.xaml.cs
83 lines (77 loc) · 2.73 KB
/
Ganar.xaml.cs
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
80
81
82
83
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Notifications;
using Windows.UI.StartScreen;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace PokeGo
{
/// <summary>
/// Una página vacía que se puede usar de forma independiente o a la que se puede navegar dentro de un objeto Frame.
/// </summary>
public sealed partial class Ganar : Page
{
public Ganar()
{
this.InitializeComponent();
}
private void imgAtras_PointerReleased(object sender, PointerRoutedEventArgs e)
{
Combate.frInicio.Navigate(typeof(Combate));
}
/// <summary>
/// Se carga una vez el Page es cargado
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Page_Loaded(object sender, RoutedEventArgs e)
{
string rutaCarpeta = "Assets"; // Ruta relativa de la carpeta dentro del proyecto
string nombreArchivo = "ganar.mp4"; // Nombre del archivo
string directorioBase = AppDomain.CurrentDomain.BaseDirectory;
string videoFilePath = Path.Combine(directorioBase, rutaCarpeta, nombreArchivo);
if (videoFilePath != null)
{
// Establece la fuente del MediaElement como el archivo de video
mediaElement.Source = new Uri(videoFilePath);
mediaElement.IsMuted = true;
mediaElement.Play();
}
notificacionGanar();
}
/// <summary>
/// Notificación al ganar la batalla
/// </summary>
private void notificacionGanar()
{
new ToastContentBuilder()
.AddArgument("action", "Favoritos")
.AddArgument("conversationId", 9813)
.AddText("Has ganado la batalla")
.AddText("Puedes ver más información en PokeGo")
.Show();
}
/// <summary>
/// Evento cuando acaba el vídeo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MediaElement_MediaEnded(object sender, RoutedEventArgs e)
{
// Reinicia el video en bucle cuando se completa la reproducción
mediaElement.Position = TimeSpan.Zero;
mediaElement.Play();
}
}
}