Exemple #1
0
		private async void goToContent (object sender, EventArgs e)
		{
			var username = user.Text;
			var pwd = password.Text;
			bool goOn = true;
			if (pwd != username.Substring (username.Length - 4)) {
				var action = await DisplayAlert ("ETC credentials", 
					             "Your credentials were not recognized.\n " +
					             "Click Continue if you want to disregard this message and contact your admin or Cancel to try again."
				, "Cancel", "Continue");
				if (action)
					goOn = false;
				else
					goOn = true;
			}
			if (goOn) {
				var Billable = new BillableTab (phoneNumber, _act);
				Billable.IsEnabled = false;
				Billable.Title = "Billable Time";
				var NonBillable = new NonBillableTab (phoneNumber, _act);
				NonBillable.IsEnabled = false;
				NonBillable.Title = "Non Billable Time";
				var masterPage = this.Parent as TabbedPage;
				masterPage.Children.Add (Billable);
				masterPage.Children.Add (NonBillable);
				masterPage.Children.Remove (this);
				masterPage.Title = "ETC Time Track";
			}
		}
        public MainContent(FormsApplicationActivity a)
        {
            act = a;
            Title = "ETC TimeApp version " + act.Resources.GetString (ETCTimeApp.Android.Resource.String.version);
            string imei = DeviceHelper.GetMyIMEI ();

            Billable = new BillableTab ();
            Billable.Title = "Billable Time";
            NonBillable = new NonBillableTab ();
            NonBillable.Title = "Non Billable Time";
            var now = DateTime.Now;
            var entries = TimeManager.GetTimeEntries ().Where (x => x.Stop != null && x.Start > now.AddDays (-15))
                .OrderByDescending(x => x.Start).ToArray();
            Entries = new EntriesTab (entries);
            Entries.Title = "History";
            Children.Add (Billable);
            Children.Add (NonBillable);
            Children.Add (Entries);

            var activeEntry = TimeManager.GetActiveTimeEntry ();
            if (activeEntry != null) {
                var timer = new Intent (a, typeof(StartLocationTimer));
                new Thread (() => Forms.Context.StartService (timer)).Start ();
            }

            ViewModel = new ActivityPageViewModel ();
            BindingContext = ViewModel;
            var activityIndicator = new ActivityIndicator {
                Color = Color.Black,
            };
            activityIndicator.SetBinding (ActivityIndicator.IsVisibleProperty, "IsBusy");
            activityIndicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsBusy");

            var menu = new ToolbarItem ();
            menu.Text = "";
            menu.Order = ToolbarItemOrder.Default;

            var hours = new ToolbarItem ();
            hours.Text = "Hours";
            hours.Order = ToolbarItemOrder.Primary;
            hours.Clicked += GetHours;

            var sync = new ToolbarItem ();
            sync.Text = "Sync";
            sync.Order = ToolbarItemOrder.Primary;
            sync.Clicked += CallSync;

            var consolidate = new ToolbarItem ();
            consolidate.Text = "Consolidate";
            consolidate.Order = ToolbarItemOrder.Primary;
            consolidate.Clicked += CallConsolidate;

            ToolbarItems.Add (menu);
            ToolbarItems.Add (hours);
            ToolbarItems.Add (sync);
            ToolbarItems.Add (consolidate);

            //			#region testing
            //			var mock = new ToolbarItem ();
            //			mock.Text = "Mock Entries";
            //			mock.Order = ToolbarItemOrder.Secondary;
            //			mock.Clicked += MockEntries;
            //
            //			var del = new ToolbarItem ();
            //			del.Text = "Delete Entries";
            //			del.Order = ToolbarItemOrder.Secondary;
            //			del.Clicked += DeleteEntries;
            //			ToolbarItems.Add (mock);
            //			ToolbarItems.Add (del);
            //			#endregion
        }