Esempio n. 1
0
        public CreateUser()
        {
            ConnectCreateUserViewModel UserVM = new ConnectCreateUserViewModel();

            Label lblPageTitle = new Label
            {
                Text     = "Nouvel utilisateur",
                FontSize = 40,
            };

            Entry EntryLogin = new Entry()
            {
                Placeholder       = "Entrez votre login",
                HorizontalOptions = LayoutOptions.Center,
                Keyboard          = Keyboard.Text,
                WidthRequest      = 400
            };

            Button btnOk = new Button()
            {
                Text = "Valider",
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.Silver
            };

            btnOk.Clicked += async(sender, args) =>
            {
                var valid = await ValidateAsync(UserVM.LoginName);

                if (valid)
                {
                    UserVM.SaveUserVM();
                    await DisplayAlert("Information", "L'utilisateur:" + UserVM.LoginName + " a été ajouté!", "OK");

                    await Navigation.PushAsync(new Connect());//SDI:We go back to the full user list
                }
            };

            var stackLayout = new StackLayout
            {
                Children =
                {
                    lblPageTitle, EntryLogin, btnOk
                },
                BackgroundColor = Color.White
            };


            EntryLogin.BindingContext = UserVM;
            EntryLogin.SetBinding(Entry.TextProperty, new Binding("LoginName"));

            this.Content         = stackLayout;
            this.Padding         = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            this.BackgroundColor = Color.Gray;
        }
Esempio n. 2
0
        public CreateTopic(ConnectCreateUserViewModel curUserVM)
        {
            TopicViewModel topicVM = new TopicViewModel(curUserVM);

            Label lblPageTitle = new Label
            {
                Text     = "Nouveau sujet",
                FontSize = 40,
            };
            Entry EntryTopic = new Entry()
            {
                Placeholder       = "Entrez votre sujet",
                HorizontalOptions = LayoutOptions.Center,
                Keyboard          = Keyboard.Text,
                WidthRequest      = 400
            };

            Button btnOk = new Button()
            {
                Text = "Valider",
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.Silver
            };

            btnOk.Clicked += async(sender, args) =>
            {
                if (await ValidateAsync(topicVM.TopicName))
                {
                    topicVM.SaveTopicVM();
                    await DisplayAlert("Information", "Le sujet:" + topicVM.TopicName + " a été ajouté!", "OK");

                    //Le modal ne marche pas bien car le retour à la page precedente ne rafraichis pas les données: A revoir
                    //await Navigation.PopModalAsync();
                    await Navigation.PushAsync(new TopicDisplay(curUserVM));//SDI:We go back to the full topics list
                }
            };



            async Task <bool> ValidateAsync(string name)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    await DisplayAlert("Information", "Le sujet: invalid", "OK");

                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            var stackLayout = new StackLayout
            {
                Children =
                {
                    lblPageTitle, EntryTopic, btnOk
                },
                BackgroundColor = Color.White
            };

            EntryTopic.BindingContext = topicVM;
            EntryTopic.SetBinding(Entry.TextProperty, new Binding("TopicName"));

            this.Content         = stackLayout;
            this.Padding         = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            this.BackgroundColor = Color.Gray;
        }
Esempio n. 3
0
        public Connect()
        {
            //this.Title = "Hierarchical Navigation";//SDI:
            ConnectCreateUserViewModel UserVM = new ConnectCreateUserViewModel();
            ListView lvAllUsers = new ListView();

            Label lblPageTitle = new Label
            {
                Text     = "Utilisateurs",
                FontSize = 40,
            };

            #region Moved to Createuser page
            //Entry EntryLogin = new Entry()
            //{
            //    Placeholder = "Entrez votre login",
            //    HorizontalOptions = LayoutOptions.FillAndExpand,
            //    Keyboard = Keyboard.Text,
            //    WidthRequest =100
            //};

            //Button btnOk = new Button()
            //{
            //    Text = "Valider",
            //    HorizontalOptions = LayoutOptions.FillAndExpand,
            //    BackgroundColor = Color.Silver
            //};

            //btnOk.Clicked += async (sender, args) =>
            //{
            //    UserVM.SaveUserVM();
            //    List<UserViewModel> AllUsersVM = UserVM.GetUsersVM();
            //    lvAllUsers.ItemsSource = AllUsersVM;
            //    lvAllUsers.ItemTemplate = new DataTemplate(typeof(TextCell));
            //    lvAllUsers.ItemTemplate.SetBinding(TextCell.TextProperty, "LoginName");
            //    lvAllUsers.ItemTemplate.SetValue(TextCell.TextColorProperty, Color.FromHex("#795548"));
            //    await DisplayAlert("Information", "new user:"******"added!", "OK");
            //};
            #endregion

            List <ConnectCreateUserViewModel> AllUsersVM = UserVM.GetUsersVM();
            if (AllUsersVM == null || (AllUsersVM != null) && AllUsersVM.Count() == 0)
            {
                //SDI: If there is no user yet,we add a "fake" user which is a link to open the CreateUser page
                ConnectCreateUserViewModel fakeToAdd = new ConnectCreateUserViewModel();
                fakeToAdd.LoginName = "Créer un utilisateur";
                AllUsersVM          = new List <ConnectCreateUserViewModel>();
                AllUsersVM.Add(fakeToAdd);
            }
            else
            {
                //SDI: we just add thefake user at the end of the list
                ConnectCreateUserViewModel fakeToAdd = new ConnectCreateUserViewModel();
                fakeToAdd.LoginName = "Créer un utilisateur";
                AllUsersVM.Add(fakeToAdd);
            }
            lvAllUsers.ItemsSource  = AllUsersVM;
            lvAllUsers.ItemTemplate = new DataTemplate(typeof(ImageCell));
            lvAllUsers.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "LoginImage");
            lvAllUsers.ItemTemplate.SetBinding(ImageCell.TextProperty, "LoginName");
            lvAllUsers.ItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("#795548"));


            lvAllUsers.ItemTapped += async(sender, e) =>
            {
                ConnectCreateUserViewModel uvm = (ConnectCreateUserViewModel)e.Item;
                if (uvm.LoginName.Trim().ToLower().Equals("créer un utilisateur"))
                {
                    //SDI: if element tapped is to create a new user, we go to the CreateUser page
                    await Navigation.PushAsync(new CreateUser());
                }
                else //SDI:This is a real user, we open the start page
                {
                    //TopicViewModel test = new TopicViewModel(uvm); ;
                    //test.DeleteAllTopics();
                    await Navigation.PushAsync(new TopicDisplay(uvm));
                }
                ((ListView)sender).SelectedItem = null;
            };

            lvAllUsers.IsPullToRefreshEnabled = true;//To enable the refreshment of the listview when pulled

            var stackLayout = new StackLayout
            {
                Children =
                {
                    lblPageTitle, lvAllUsers
                },
                BackgroundColor = Color.White
            };


            this.Content         = stackLayout;
            this.Padding         = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            this.BackgroundColor = Color.Gray;
        }
Esempio n. 4
0
        public TopicDisplay(ConnectCreateUserViewModel _curUserVM)
        {
            TopicViewModel curTopicVM  = new TopicViewModel(_curUserVM);
            ListView       lvAllTopics = new ListView();

            Label lblPageTitle = new Label
            {
                Text     = "Vos matières",
                FontSize = 40,
            };

            Label lblUserConnected = new Label
            {
                Text           = "Bon apprentissage, " + _curUserVM.LoginName + " !",
                FontSize       = 15,
                FontAttributes = FontAttributes.Italic,
                TextColor      = Color.FromHex("#607d8b")
            };


            List <TopicViewModel> AllTopicsVM = curTopicVM.GetTopicsForUserVM(_curUserVM);

            if (AllTopicsVM == null || (AllTopicsVM != null) && AllTopicsVM.Count() == 0)
            {
                //SDI: If there is no topic yet,we add a "fake" topic which is a link to open the CreateTopic page
                TopicViewModel fakeToAdd = new TopicViewModel(_curUserVM);
                fakeToAdd.TopicName = "Créer un sujet";
                AllTopicsVM         = new List <TopicViewModel>();
                AllTopicsVM.Add(fakeToAdd);
            }
            else
            {
                //SDI: we just add the fake topic at the end of the list
                TopicViewModel fakeToAdd = new TopicViewModel(_curUserVM);
                fakeToAdd.TopicName = "Créer un sujet";
                AllTopicsVM.Add(fakeToAdd);
            }
            lvAllTopics.ItemsSource  = AllTopicsVM;
            lvAllTopics.ItemTemplate = new DataTemplate(typeof(ImageCell));
            lvAllTopics.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "TopicImage");
            lvAllTopics.ItemTemplate.SetBinding(ImageCell.TextProperty, "TopicName");
            lvAllTopics.ItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("#795548"));

            lvAllTopics.ItemTapped += async(sender, e) =>
            {
                TopicViewModel tvm = (TopicViewModel)e.Item;
                if (tvm.TopicName.Trim().ToLower().Equals("créer un sujet"))
                {
                    //SDI: if element tapped is to create a new topic, we go to the CreateTopic page
                    //Le modal ne marche pas bien car le retour à la page precedente ne rafraichis pas les données: A revoir //await Navigation.PushModalAsync(new CreateTopic(_curUserVM));
                    await Navigation.PushAsync(new CreateTopic(_curUserVM));
                }
                else //SDI:This is an existing Topic, we open the Chapter page
                {
                    await Navigation.PushAsync(new ChapterDisplay(tvm));

                    //await DisplayAlert("Tapped", tvm.TopicName.ToString() + " was selected.", "OK","Cancel");
                }
                ((ListView)sender).SelectedItem = null;
            };

            lvAllTopics.IsPullToRefreshEnabled = true;//To enable the refreshment of the listview when pulled

            var stackLayout = new StackLayout
            {
                Children =
                {
                    lblPageTitle, lblUserConnected, lvAllTopics
                },
                BackgroundColor = Color.White
            };

            this.Content         = stackLayout;
            this.Padding         = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            this.BackgroundColor = Color.Gray;
        }