using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; namespace MagusEvents { /// /// Interaction logic for header.xaml /// /// public partial class header : Page { DispatcherTimer DateClock = new DispatcherTimer(); Webservices online = new Webservices(); Database DATA = new Database(); public int offline = 0; public header() { InitializeComponent(); string path = @"c:\temp_acc\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string file = @"c:\temp_acc\meal.txt"; if (!File.Exists(file)) { File.CreateText(file); } file = @"c:\temp_acc\scan.txt"; if (!File.Exists(file)) { File.CreateText(file); } getEVent(); DateClock = new DispatcherTimer(); DateClock.Interval = TimeSpan.FromSeconds(1); DateClock.Tick += new EventHandler(get_date); DateClock.Start(); } private int ID = 0; private void get_date(object sender, EventArgs e) { //LOAD CLOCK WITH TIMER Global_time.Content = DateTime.Now.ToString("HH:mm"); Date_Date.Content = DateTime.Now.ToString("dddd, d MMMM"); bool is_online = online.CheckForInternetConnection(); if (is_online == true) { offline = 1; Online.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF01CF0B")); //Download_Image(); } else { offline = 0; Online.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F00")); } } public void getEVent() { Global_time.Content = DateTime.Now.ToString("HH:mm"); Date_Date.Content = DateTime.Now.ToString("dddd, d MMMM"); ID = DATA.GetAccreditationID(); if (ID > 0) { Events Eventsprofile = DATA.GetEvent(ID.ToString()); Tournament_Name.Content = Eventsprofile.AccreditationName; Tournament_Date.Content = Eventsprofile.DateFrom; Tournament_Venue.Content = Eventsprofile.Location; if (Eventsprofile.Logo!="") { EventLogo.Source = Base64StringToBitmap(Eventsprofile.Logo); } } } public static BitmapImage Base64StringToBitmap(string base64String) { var imgBytes = Convert.FromBase64String(base64String); BitmapImage bitmapImage = new BitmapImage(); MemoryStream ms = new MemoryStream(imgBytes); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms; bitmapImage.EndInit(); return bitmapImage; } private void ExitApp(object sender, MouseButtonEventArgs e) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to close the application?", "Exit", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { Application.Current.Shutdown(); } } } }