Beispiel #1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            /// Project Class Member variable
            var nameLbl = new Label {
                Text = "Name"
            };
            var nameEntry = new Entry();

            nameEntry.SetBinding(Entry.TextProperty, "name");

            var deadlineLbl = new Label {
                Text = "Deadline"
            };
            var deadlinePicker = new DatePicker();

            deadlinePicker.SetBinding(DatePicker.DateProperty, "deadline");

            var isTeamLbl = new Label {
                Text = "Team Project"
            };
            var isTeamSwitch = new Switch();

            isTeamSwitch.SetBinding(Switch.IsToggledProperty, "isTeam");
            if (idx != -1)
            {
                isTeamSwitch.IsEnabled = false;
            }

            // File List
            fileList = new ListView
            {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(Views.FileCell))
            };
            fileList.ItemTemplate.SetBinding(FileCell.idxProperty, "Idx");
            fileList.SetBinding(ListView.ItemsSourceProperty, "fileList");
            if (idx != -1)
            {
                fileList.ItemsSource = dao.GetFileList();
            }
            fileList.ItemSelected += FileList_ItemSelected;
            fileUrlEntry           = new Entry {
                Placeholder = "URL", WidthRequest = 200, HeightRequest = 30
            };
            fileAddBtn = new Button {
                Text = "+", WidthRequest = 30, HeightRequest = 30, Margin = 0
            };
            fileAddBtn.Clicked += FileAddBtn_Clicked;

            fileLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label {
                        Text = "File list"
                    },
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Orientation     = StackOrientation.Horizontal,
                        Children        =
                        {
                            fileUrlEntry,
                            fileAddBtn
                        }
                    },
                    fileList,
                }
            };

            // Comment List
            commentList = new ListView
            {
                RowHeight              = 40,
                ItemTemplate           = new DataTemplate(typeof(Views.CommentCell)),
                IsPullToRefreshEnabled = true
            };
            commentList.ItemTemplate.SetBinding(CommentCell.idxProperty, "Idx");
            commentList.SetBinding(ListView.ItemsSourceProperty, "commentList");
            if (idx != -1)
            {
                commentList.ItemsSource = dao.GetCommentList();
            }
            commentList.RefreshCommand = new Command(() =>
            {
                commentList.ItemsSource  = dao.GetCommentList();
                commentList.IsRefreshing = false;
            });
            commentList.ItemSelected += CommentList_ItemSelected;
            commentAddBtn             = new Button {
                Text = "+", WidthRequest = 30, HeightRequest = 30
            };
            commentEntry = new Entry {
                WidthRequest = 300
            };
            commentEntry.SetBinding(Entry.TextProperty, "comment");
            commentAddBtn.Clicked += CommentAddBtn_Clicked;

            commentLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label {
                        Text = "Comment list"
                    },
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Orientation     = StackOrientation.Horizontal,
                        Children        =
                        {
                            commentEntry,
                            commentAddBtn
                        }
                    },
                    commentList,
                }
            };


            // Team List
            var teamList = new ListView
            {
                RowHeight = 40,
//				ItemTemplate = new DataTemplate(typeof(TeamCell)),
            };

            if (idx != -1)
            {
                teamList.ItemsSource = dao.GetTeamUser();
            }
//			teamList.SetBinding(ListView.ItemsSourceProperty, "teamList");
            var teamAddBtn = new Button {
                Text = "+", WidthRequest = 30, HeightRequest = 30
            };

            teamEntry = new Entry {
                WidthRequest = 300
            };
            teamAddBtn.Clicked += TeamAddBtn_Clicked;

            var teamLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label {
                        Text = "Team Member list"
                    },
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Orientation     = StackOrientation.Horizontal,
                        Children        =
                        {
                            teamEntry,
                            teamAddBtn
                        }
                    },
                    teamList,
                }
            };

            // Todo List
            TodoListView todolistView = new TodoListView(idx);
            var          todoLayout   = new StackLayout
            {
                Children =
                {
                    new Label {
                        Text = "Todo list"
                    },
                    todolistView
                }
            };

            // Buttons
            var saveButton = new Button {
                Text = "Save"
            };

            saveButton.Clicked += SaveButton_Clicked;

            var deleteButton = new Button {
                Text = "Delete"
            };

            deleteButton.Clicked += DeleteButton_Clicked;

            var cancelButton = new Button {
                Text = "Cancel"
            };

            cancelButton.Clicked += CancelButton_Clicked;

            var layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding         = new Thickness(20),
                Children        =
                {
                    nameLbl,     nameEntry,
                    deadlineLbl, deadlinePicker,
                    isTeamLbl,   isTeamSwitch
                }
            };

            if (idx != -1)
            {
                todolistView.BindingContext = dao.GetTodo();

                layout.Children.Add(fileLayout);
                layout.Children.Add(commentLayout);
                layout.Children.Add(todoLayout);

                if (((Project)this.BindingContext).isTeam)
                {
                    layout.Children.Add(teamLayout);
                }
            }
            layout.Children.Add(saveButton);
            layout.Children.Add(cancelButton);
            if (idx != -1)
            {
                layout.Children.Add(deleteButton);
            }

            scrollView         = new ScrollView();
            scrollView.Content = layout;

            Content = scrollView;
        }