Ejemplo n.º 1
0
 /// <summary>
 /// Register the current project
 /// </summary>
 /// <param name="projectGUID"></param>
 public static void SetProject(string projectGUID)
 {
     Task.Run(() =>
     {
         RecordLists          = new RecordListModel();
         var projectId        = projectGUID.ToString();
         App.CurrentProjectId = projectId;
         Preferences.Set("currentProject", projectId);
         AppShell.ClearNavigationStacks();
         MessagingCenter.Send(App.Current, "SetProject");
         RecordLists.CreateRecordLists();
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialisation with os dependent parameter inputs. Start listening for a login return
        /// </summary>
        /// <param name="databaseLocation"></param>
        /// <param name="tileLocation"></param>
        public App(string databaseLocation, string tileLocation)
        {
            InitializeComponent();
            Device.SetFlags(new string[] { "RadioButton_Experimental", "Shapes_Experimental", "Expander_Experimental" });

            RecordLists = new RecordListModel();
            CurrentUser = User.RetrieveUser();
            BioDivPrefs = new BioDivPreferences();
            Preferences.Set("databaseLocation", databaseLocation);
            TileLocation     = tileLocation;
            CurrentProjectId = Preferences.Get("currentProject", "");
            RecordLists.CreateRecordLists();
            Busy = false;
            CheckConnection();

            VersionTracking.Track();

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "LoginSuccessful", (sender) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    BioDivCollectorXamarin.Models.LoginModel.Login.GetUserDetails();

                    MainPage = new AppShell();
                    if (CurrentRoute != null && CurrentRoute != String.Empty)
                    {
                        try { AppShell.Current.GoToAsync(CurrentRoute); }
                        catch (Exception e)
                        {
                            Console.WriteLine("Didn't manage to go to route, " + e);
                        }
                    }
                });
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "LoginUnsuccessful", (sender) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    MainPage = Login.GetPageToView();
                });
            });
        }