public MainWindow()
        {
            InitializeComponent();

            #region Variables Initialization
            loggedIn              = false;
            CurrentVM             = new FallVM();
            userVM                = new UserVM();
            currentLang           = "Resources/ukFlagIcon.png";
            CurrentUser           = new user();
            CurrentUser.firstname = "Guest";
            main   = new MainUserControl();
            login  = new LoginUserControl(this);
            report = new ReportUserControl(this);
            #endregion

            #region Preparing the Source of the Falls Listbox
            userControlGrid.Children.Add(main);
            foreach (var fall in CurrentVM.Falls)
            {
                Pushpin pushpin = new Pushpin();
                pushpin.Name       = "pushpin" + fall.id.ToString();
                pushpin.Location   = new Location(fall.x, fall.y);
                pushpin.Background = System.Windows.Media.Brushes.Orange;
                main.fallsView.Children.Add(pushpin);
            }
            main.fallsListBox.ItemsSource = CurrentVM.Falls.OrderByDescending(fall => fall.date);
            #endregion

            #region Handling the previous "Recent" Reports
            // We want to make sure that, if recentFalls still reports from a previous day(s),
            // it will be cleared before we start storing reports on it today.
            XElement prevFallsRoot = XElement.Load("recentFalls.xml");
            if (prevFallsRoot.HasElements)
            {
                IEnumerable <XElement> prevFallsList = prevFallsRoot.Elements("Fall").ToList();
                DateTime lastReport = new DateTime(0);
                foreach (XElement fallRep in prevFallsList)
                {
                    DateTime leDate = DateTime.Now;
                    DateTime.TryParse(fallRep.Element("Date").Value, out leDate);
                    if (leDate.CompareTo(lastReport) > 0)
                    {
                        lastReport = leDate;
                    }
                }
                if (lastReport.Day != DateTime.Now.Day || lastReport.Month != DateTime.Now.Month || lastReport.Year != DateTime.Now.Year)
                {
                    // This is where we'd first save the previous days reports on a more permanent
                    // storage on the cloud, if we wanted to do that
                    File.WriteAllText(@"recentFalls.xml", string.Empty);
                }
            }
            #endregion
        }
 public void MainButton_Click(object sender, RoutedEventArgs e)
 {
     mainButton.BorderThickness   = new Thickness(0, 0, 0, 2);
     mainButton.FontWeight        = FontWeights.ExtraBold;
     loginButton.BorderThickness  = new Thickness(0, 0, 0, 0);
     loginButton.FontWeight       = FontWeights.Normal;
     reportButton.BorderThickness = new Thickness(0, 0, 0, 0);
     reportButton.FontWeight      = FontWeights.Normal;
     updateButton.BorderThickness = new Thickness(0, 0, 0, 0);
     updateButton.FontWeight      = FontWeights.Normal;
     userControlGrid.Children.RemoveAt(0);
     main = new MainUserControl();
     userControlGrid.Children.Add(main);
     CurrentVM = new FallVM();
     foreach (var fall in CurrentVM.Falls)
     {
         Pushpin pushpin = new Pushpin();
         pushpin.Name       = "pushpin" + fall.id.ToString();
         pushpin.Location   = new Location(fall.x, fall.y);
         pushpin.Background = System.Windows.Media.Brushes.Orange;
         main.fallsView.Children.Add(pushpin);
     }
     main.fallsListBox.ItemsSource = CurrentVM.Falls.OrderByDescending(fall => fall.date);
 }