public InformationPage() { BackgroundColor = GeneralSettings.backgroundColor; //Haal de informatie op uit de database InfoObj = (List <InformationObject>)ContactDataBase.GetInformation(ContactDataBase.currentUserName, ContactDataBase.currentToken); StackLayout stack = new StackLayout() { VerticalOptions = LayoutOptions.Center, Margin = GeneralSettings.pageMargin }; //Maakt iteratief ClickableLabels aan foreach (InformationObject b in InfoObj) { stack.Children.Add(new ClickableLabel(VolgendePagina, 24) { Text = b.Name, TextColor = GeneralSettings.textColor, HorizontalOptions = LayoutOptions.CenterAndExpand }); } ScrollView scroll = new ScrollView() { Content = stack }; Content = scroll; }
private async void Table_ItemTapped(object sender, ItemTappedEventArgs e) { table.IsEnabled = false; Project f = (Project)e.Item; var tokenSource2 = new CancellationTokenSource(); await System.Threading.Tasks.Task.Run(() => { Boolean hasAccess = true; Sprint s = null; //Krijg taken en sprints van database try { f.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); s = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); } catch { hasAccess = false; } try { //Voeg taken en sprints toe List <Task> tasks = new List <Task>(); foreach (Task t in f.Tasks) { if (s != null && t.sprintid == s.sprintid) { tasks.Add(t); } } if (s != null) { s.Sprinttasks = tasks; f.CurrentSprint = s; } } catch { } //Laat normale pagina of join pagina zien (afhankelijk van hasAccess) Device.BeginInvokeOnMainThread(() => { if (hasAccess) { Navigation.PushAsync(new TabbedPage() { Children = { new ProjectInfoPage(f), new SprintPage(f.CurrentSprint, f.Tasks, f), new NewSprintPage(f), new burndown(f) }, Title = f.projectname }); } else { Navigation.PushAsync(new TabbedPage() { Children = { new JoinProjectPage(f), }, Title = f.projectname, BackgroundColor = GeneralSettings.mainColor }); } }); }, tokenSource2.Token); tokenSource2.Cancel(); table.IsEnabled = true; }
//Complete task private void CompleteTask_Clicked(object sender, EventArgs e) { try { ContactDataBase.completeTask(ContactDataBase.currentUserName, ContactDataBase.currentToken, t.taskid, t.projectid); refreshPage(); } catch { } }
//Join task private void JointTask_Clicked(object sender, EventArgs e) { if (t.lastname == null && t.firstname == null) { t.firstname = ContactDataBase.currentUser.firstname; t.lastname = ContactDataBase.currentUser.lastname; ContactDataBase.JoinTask(ContactDataBase.currentUserName, ContactDataBase.currentToken, t.taskid, t.projectid); refreshPage(); } }
//Uitloggen (Destroy token) private void LogOut(object sender, EventArgs e) { String loginResult = (string)ContactDataBase.logOut(ContactDataBase.currentUserName, ContactDataBase.currentToken); if (loginResult == "TK_DESTROY_SUCCESS") { App.Current.MainPage = new NavigationPage(new Login()) { BarBackgroundColor = GeneralSettings.mainColor, Title = "test", BarTextColor = GeneralSettings.textColor }; } }
//Eventhandler voor de signIn button private async void SignInClicked(object sender, EventArgs e) { signIn.IsEnabled = false; working.IsRunning = true; // this.IsBusy = true; //De workload verdelen over meerdere Threads var tokenSource2 = new CancellationTokenSource(); await System.Threading.Tasks.Task.Run(() => { if (this.rememberMe.IsToggled) { //Als er wordt opgeslagen moet de oude er uit, anders krijg je twee opgeslagen waarden DeleteCredentials(); SaveCredentials(userName.Text, password.Text); } else { //Als iemand rememberme uit zet moet het verwijderd worden DeleteCredentials(); } //Opslaan van de switch stand var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var filename = Path.Combine(documents, "MySettings.txt"); File.WriteAllText(filename, this.rememberMe.IsToggled.ToString()); string s1 = (string)ContactDataBase.SingIn(userName.Text, password.Text); Device.BeginInvokeOnMainThread(() => { if (s1.Length == 120) { ContactDataBase.currentToken = s1; ContactDataBase.currentUserName = userName.Text; //Zet de currentUser in de ContactDateBase klasse ContactDataBase.currentUser = (User)ContactDataBase.GetUserInfo(ContactDataBase.currentUserName, ContactDataBase.currentToken); Application.Current.MainPage = new NavigationPage(new HomePage()) { BarBackgroundColor = GeneralSettings.mainColor, BarTextColor = GeneralSettings.btextColor }; } else { System.Diagnostics.Debug.WriteLine(s1); signIn.IsEnabled = true; warning.Text = Globals.warnlogin; working.IsRunning = false; } }); }, tokenSource2.Token); tokenSource2.Cancel(); }
private async void B_Clicked(object sender, EventArgs e) { b.IsEnabled = false; //Nieuw project toevoegen aan de database ContactDataBase.createProject(ContactDataBase.currentUserName, ContactDataBase.currentToken, nameEntry.Text, descriptionEntry.Text, start.Date); await Navigation.PushAsync(new ProjectsPage((List <Project>)ContactDataBase.GetProjects(ContactDataBase.currentUserName, ContactDataBase.currentToken)), false); //Het verwijderen van de oude pages in de stack for (int counter = 1; counter <= 2; counter++) { Navigation.RemovePage(Navigation.NavigationStack[1]); } }
private async void AddTask(object sender, EventArgs e) { addTask.IsEnabled = false; int projectID; //De nieuwe taak toevoegen aan project in de database try { projectID = saved.projectid; ContactDataBase.addTaskToProject(ContactDataBase.currentUserName, ContactDataBase.currentToken, nameEntry.Text, descriptionEntry.Text, project.projectid, int.Parse(rroeValueEntry.Text), int.Parse(jobSizeEntry.Text), int.Parse(userBusinessValueEntry.Text), int.Parse(timeCriticalityEntry.Text), int.Parse(uncertaintyEntry.Text)); List <Project> projects = (List <Project>)ContactDataBase.GetProjects(ContactDataBase.currentUserName, ContactDataBase.currentToken); foreach (Project project in projects) { if (project.projectid == projectID) { project.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); Sprint s = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); List <Task> tasks = new List <Task>(); foreach (Task t in project.Tasks) { if (s != null && t.sprintid == s.sprintid) { tasks.Add(t); } } if (s != null) { s.Sprinttasks = tasks; project.CurrentSprint = s; } await Navigation.PushAsync(new TabbedPage() { Children = { new ProjectInfoPage(project), new SprintPage(project.CurrentSprint, project.Tasks, project), new NewSprintPage(project), new burndown(project) }, Title = project.projectname }); } } // Het verwijderen van de oude pages in de stack for (int counter = 1; counter <= 2; counter++) { Navigation.RemovePage(Navigation.NavigationStack[2]); } addTask.IsEnabled = true; } //Opvangen error catch { await DisplayAlert(Globals.taakallerttitel, Globals.taakallertmessage, "ok"); addTask.IsEnabled = true; } }
// maak een url aan om het wachtwoord te veranderen private void pushed(object sender, EventArgs e) { change.IsEnabled = false; //Check NEW_PASS success if ((string)ContactDataBase.UpdatePasword(ContactDataBase.currentUserName, ContactDataBase.currentToken, oudwachtwoord.Text, nieuwWachtwoord.Text) == "NEW_PASS_HAS_BEEN_SET") { Navigation.PopAsync(); } else { //Error message warning.Text = Globals.VWerror; } }
//De data wordt opgestuurd en de ouput vergeleken private void B_Clicked(object sender, EventArgs e) { createNewUser.IsEnabled = false; //Controleer NEW_USER success if ((string)ContactDataBase.CreateUser(username.Text, password.Text, fName.Text, lName.Text, joincode.Text) == "NEW_USER_SUCCESS") { DisplayAlert("Nieuw Account", "Aanmaken succesvol. U heeft een email ontvangen met een link om het account te verifiëren", "OK"); Navigation.PopAsync(); } else { //Error message warning.Text = Globals.nieuwaccfail; } createNewUser.IsEnabled = true; }
//Maak url aan om email te veranderen private void butonclicked(object sender, EventArgs e) { change_W8.IsEnabled = false; //Check NEW_EMAIL success if ((string)ContactDataBase.UpdateEmail(ContactDataBase.currentUserName, ContactDataBase.currentToken, wachtwoord.Text, nieuwEmail.Text) == "NEW_EMAIL_HAS_BEEN_SET") { Application.Current.MainPage = new NavigationPage(new Login()) { BarBackgroundColor = GeneralSettings.mainColor, Title = "test", BarTextColor = GeneralSettings.textColor }; } else { //Error message Error.Text = Globals.VEerror; } }
//Refresh de pagina private async void refreshPage() { int projectID = t.projectid; try { List <Project> projects = (List <Project>)ContactDataBase.GetProjects(ContactDataBase.currentUserName, ContactDataBase.currentToken); foreach (Project project in projects) { if (project.projectid == projectID) { project.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); Sprint s = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); List <Task> tasks = new List <Task>(); foreach (Task t in project.Tasks) { if (s != null && t.sprintid == s.sprintid) { tasks.Add(t); } } if (s != null) { s.Sprinttasks = tasks; project.CurrentSprint = s; } await Navigation.PushAsync(new TabbedPage() { Children = { new ProjectInfoPage(project), new SprintPage(project.CurrentSprint, project.Tasks, project), new NewSprintPage(project), new burndown(project) }, Title = project.projectname }); } } // Het verwijderen van de oude pages in de stack for (int counter = 1; counter <= 2; counter++) { Navigation.RemovePage(Navigation.NavigationStack[2]); } } catch { //error opvangen await DisplayAlert(Globals.taakallerttitel, Globals.taakallertmessage, "ok"); } }
//Nieuwe sprint aan database toevoegen private async void newSprintClicked(object sender, EventArgs e) { ContactDataBase.createNewSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, sprintName.Text, Convert.ToInt32(sprintDuration.Text), Convert.ToInt32(tPoints.Text), startDate.Date, this.project.projectid); project.CurrentSprint = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); project.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, project.projectid); //Push de nieuwe pagina op de stack var page1 = new ProjectInfoPage(project); var page2 = new SprintPage(project.CurrentSprint, project.Tasks, project); var page3 = new NewSprintPage(project); var page4 = new burndown(project); await Navigation.PushAsync(new TabbedPage() { Children = { page1, page2, page3, page4 }, Title = project.projectname, BackgroundColor = GeneralSettings.backgroundColor, CurrentPage = page2 }); //Verweider de oude pagina's uit de stack Navigation.RemovePage(Navigation.NavigationStack[2]); }
private async void ProjectButtonClicked(object sender, EventArgs e) { //Animeren van de knop await projectImage.ScaleTo(0.9, 100); await projectImage.ScaleTo(1, 100); var tokenSource2 = new CancellationTokenSource(); //Een nieuwe thread openen await System.Threading.Tasks.Task.Run(() => { List <Project> s = (List <Project>)ContactDataBase.GetProjects(ContactDataBase.currentUserName, ContactDataBase.currentToken); Device.BeginInvokeOnMainThread(() => { //Zet de nieuwe pagina op de stack. Navigation.PushAsync(new ProjectsPage(s)); }); }, tokenSource2.Token); //Sluit de thread af tokenSource2.Cancel(); }
//Taak toevoegen aan de sprint private async void AddTaskClicked(object sender, EventArgs e) { Task s = (Task)table.SelectedItem; ContactDataBase.addTaskToSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, s.taskid, s.projectid, sprint.sprintid); f.CurrentSprint = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); f.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); List <Task> tasks2 = new List <Task>(); foreach (Task t in f.Tasks) { if (s != null && t.sprintid == f.CurrentSprint.sprintid) { tasks2.Add(t); } } if (s != null) { f.CurrentSprint.Sprinttasks = tasks2; } var page1 = new ProjectInfoPage(f); var page2 = new SprintPage(f.CurrentSprint, f.Tasks, f); var page3 = new NewSprintPage(f); var page4 = new burndown(f); //Push de nieuwe pagina op de stack await Navigation.PushAsync(new TabbedPage() { Children = { page1, page2, page3, page4 }, Title = f.projectname, BackgroundColor = GeneralSettings.backgroundColor, CurrentPage = page2 }); //Verweider de oude pagina's uit de stack for (int counter = 1; counter <= 2; counter++) { Navigation.RemovePage(Navigation.NavigationStack[2]); } }
//Voeg gebruiker toe aan project private async void B_Clicked(object sender, EventArgs e) { b.IsEnabled = false; string userName = ContactDataBase.currentUserName; string token = ContactDataBase.currentToken; int projectID = ding.projectid; //Controleer JOIN_PROJECT_SUCCESS if ((string)ContactDataBase.JoinProject(userName, token, projectID) == "JOIN_PROJECT_SUCCESS") { //Popup success await DisplayAlert(Globals.joinpassname, Globals.joinpass, Globals.okknop); Project f = ding; var tokenSource2 = new CancellationTokenSource(); await System.Threading.Tasks.Task.Run(() => { Boolean hasAccess = true; Sprint s = null; //Krijg taken en sprints van database try { f.Tasks = (List <Task>)ContactDataBase.GetTasks(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); s = (Sprint)ContactDataBase.GetSprint(ContactDataBase.currentUserName, ContactDataBase.currentToken, f.projectid); } catch { hasAccess = false; } try { //Voeg taken en sprints toe List <Task> tasks = new List <Task>(); foreach (Task t in f.Tasks) { if (s != null && t.sprintid == s.sprintid) { tasks.Add(t); } } if (s != null) { s.Sprinttasks = tasks; f.CurrentSprint = s; } } catch { } //Laat normale pagina of join pagina zien (afhankelijk van hasAccess) Device.BeginInvokeOnMainThread(() => { if (hasAccess) { Navigation.PushAsync(new TabbedPage() { Children = { new ProjectInfoPage(f), new SprintPage(f.CurrentSprint, f.Tasks, f), new NewSprintPage(f), new burndown(f) }, Title = f.projectname }); } else { Navigation.PushAsync(new TabbedPage() { Children = { new JoinProjectPage(f), }, Title = f.projectname, BackgroundColor = GeneralSettings.mainColor }); } }); }, tokenSource2.Token); tokenSource2.Cancel(); } //error JOIN_PROJECT niet gelukt else { await DisplayAlert(Globals.error, Globals.joinfail, Globals.okknop); b.IsEnabled = true; } Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]); }