Ejemplo n.º 1
0
        private void InitialiseElements()
        {
            Label labelTitle = new Label()
            {
                Text       = "Edit",
                FontSize   = 24,
                FontFamily = "Roboto",
                TextColor  = Constants.TextColor,
                HorizontalTextAlignment = TextAlignment.Center
            };

            Label labelStarted = new Label()
            {
                Text       = "Started",
                FontSize   = 24,
                FontFamily = "Roboto",
                TextColor  = Constants.TextColor,
                HorizontalTextAlignment = TextAlignment.Start
            };

            Label labelEnded = new Label()
            {
                Text       = "Ended",
                FontSize   = 24,
                FontFamily = "Roboto",
                TextColor  = Constants.TextColor,
                HorizontalTextAlignment = TextAlignment.Start
            };

            labelEnded.SetBinding(Label.IsVisibleProperty, "EndPickersVisible");

            ImageButton btnBackArrow = new ImageButton()
            {
                Source = "backarrow.png",
                Aspect = Aspect.Fill
            };

            btnBackArrow.SetBinding(ImageButton.TappedCommandProperty, "BackButtonCommand");

            ImageButton btnAccept = new ImageButton()
            {
                Aspect = Aspect.Fill
            };

            btnAccept.SetBinding(ImageButton.SourceProperty, "AcceptButtonImage");
            btnAccept.SetBinding(ImageButton.TappedCommandProperty, "AcceptButtonCommand");
            btnAccept.SetBinding(ImageButton.IsEnabledProperty, "AcceptButtonEnabled", BindingMode.TwoWay);

            ImageButton btnDelete = new ImageButton()
            {
                Source = "deletebtn.png",
                Aspect = Aspect.Fill
            };

            btnDelete.SetBinding(ImageButton.TappedCommandProperty, "DeleteButtonCommand");
            btnDelete.SetBinding(ImageButton.IsEnabledProperty, "DeleteButtonEnabled", BindingMode.TwoWay);

            DatePicker dpStartDate = new DatePicker()
            {
                Format    = Constants.DateFormat,
                TextColor = Constants.TextColor
            };

            dpStartDate.SetBinding(DatePicker.DateProperty, "StartDate", BindingMode.TwoWay);
            dpStartDate.SetBinding(DatePicker.MaximumDateProperty, "MaximumStartDate");

            TimePicker tpStartTime = new TimePicker()
            {
                Format    = Constants.TimeSecondsFormat,
                TextColor = Constants.TextColor
            };

            tpStartTime.SetBinding(TimePicker.TimeProperty, "StartTime", BindingMode.TwoWay);

            DatePicker dpEndDate = new DatePicker()
            {
                Format    = Constants.DateFormat,
                TextColor = Constants.TextColor
            };

            dpEndDate.SetBinding(DatePicker.DateProperty, "EndDate", BindingMode.TwoWay);
            dpEndDate.SetBinding(DatePicker.MinimumDateProperty, "MinimumEndDate");
            dpEndDate.SetBinding(DatePicker.IsVisibleProperty, "EndPickersVisible");

            TimePicker tpEndTime = new TimePicker()
            {
                Format    = Constants.TimeSecondsFormat,
                TextColor = Constants.TextColor
            };

            tpEndTime.SetBinding(TimePicker.TimeProperty, "EndTime", BindingMode.TwoWay);
            tpEndTime.SetBinding(TimePicker.IsVisibleProperty, "EndPickersVisible");

            rl.AddView(btnBackArrow, Constraint.RelativeToParent((p) =>
            {
                return(p.X + 10);
            }),
                       Constraint.RelativeToParent((p) =>
            {
                return(p.Y + 10);
            }),
                       Constraint.Constant(32),
                       Constraint.Constant(32)
                       );

            rl.AddView(btnDelete, Constraint.RelativeToParent((p) =>
            {
                return(p.Width - 10 - 40);
            }),
                       Constraint.RelativeToParent((p) =>
            {
                return(p.Y + 10);
            }),
                       Constraint.Constant(40),
                       Constraint.Constant(40)
                       );

            rl.AddView(labelTitle, Constraint.RelativeToParent((p) =>
            {
                return(p.X);
            }),
                       Constraint.RelativeToParent((p) =>
            {
                return(p.Y + 55);
            }),
                       Constraint.RelativeToParent((p) =>
            {
                return(p.Width);
            }),
                       Constraint.Constant(32)
                       );

            int indent = 42;

            rl.AddView(labelStarted, Constraint.RelativeToParent((p) =>
            {
                return(p.X + indent);
            }),
                       Constraint.RelativeToView(labelTitle, (p, s) =>
            {
                return(s.Y + s.Height + 120);
            }),
                       Constraint.Constant(150),
                       Constraint.Constant(32)
                       );

            int buffer = 10;
            int margin = 10;
            int height = 40;

            rl.AddView(dpStartDate, Constraint.RelativeToView(labelStarted, (p, s) =>
            {
                return(s.X);
            }),
                       Constraint.RelativeToView(labelStarted, (p, s) =>
            {
                return(s.Y + s.Height + 10);
            }),
                       Constraint.RelativeToView(labelStarted, (p, s) =>
            {
                return(((p.Width - indent - margin) / 2) - buffer / 2);
            }),
                       Constraint.Constant(height)
                       );

            rl.AddView(tpStartTime, Constraint.RelativeToView(dpStartDate, (p, s) =>
            {
                return(s.X + s.Width + (buffer / 2));
            }),
                       Constraint.RelativeToView(dpStartDate, (p, s) =>
            {
                return(s.Y);
            }),
                       Constraint.RelativeToView(dpStartDate, (p, s) =>
            {
                return(s.Width);
            }),
                       Constraint.Constant(height)
                       );

            rl.AddView(labelEnded, Constraint.RelativeToParent((p) =>
            {
                return(p.X + indent);
            }),
                       Constraint.RelativeToView(labelStarted, (p, s) =>
            {
                return(s.Y + s.Height + 75);
            }),
                       Constraint.Constant(150),
                       Constraint.Constant(32)
                       );

            rl.AddView(dpEndDate, Constraint.RelativeToView(labelEnded, (p, s) =>
            {
                return(s.X);
            }),
                       Constraint.RelativeToView(labelEnded, (p, s) =>
            {
                return(s.Y + s.Height + 10);
            }),
                       Constraint.RelativeToView(labelEnded, (p, s) =>
            {
                return(((p.Width - indent - margin) / 2) - buffer / 2);
            }),
                       Constraint.Constant(height)
                       );

            rl.AddView(tpEndTime, Constraint.RelativeToView(dpEndDate, (p, s) =>
            {
                return(s.X + s.Width + (buffer / 2));
            }),
                       Constraint.RelativeToView(dpEndDate, (p, s) =>
            {
                return(s.Y);
            }),
                       Constraint.RelativeToView(dpEndDate, (p, s) =>
            {
                return(s.Width);
            }),
                       Constraint.Constant(height)
                       );

            int acceptBtnWidth  = 103;
            int acceptBtnHeight = 41;

            rl.AddView(btnAccept, Constraint.RelativeToParent((p) =>
            {
                return(p.Width / 2 - acceptBtnWidth / 2);
            }),
                       Constraint.RelativeToParent((p) =>
            {
                return(p.Height - acceptBtnHeight - 70);
            }),
                       Constraint.Constant(acceptBtnWidth),
                       Constraint.Constant(acceptBtnHeight)
                       );
        }
Ejemplo n.º 2
0
        private void InitialiseElements()
        {
            #region ViewInitialisation
            ImageButton imgBackBtn = new ImageButton()
            {
                Source = "backarrow.png",
                Aspect = Aspect.Fill
            };
            imgBackBtn.SetBinding(ImageButton.TappedCommandProperty, "BackButtonCommand");
            imgBackBtn.SetBinding(ImageButton.IsEnabledProperty, "BackButtonEnabled", BindingMode.TwoWay);

            ImageButton imgEditActivityBtn = new ImageButton()
            {
                Source = "editbtn.png",
                Aspect = Aspect.AspectFill
            };
            imgEditActivityBtn.SetBinding(ImageButton.TappedCommandProperty, "EditActivityButtonCommand");
            imgEditActivityBtn.SetBinding(ImageButton.IsEnabledProperty, "EditActivityButtonEnabled", BindingMode.TwoWay);

            Image imgBg = new Image()
            {
                Source          = "activitypagebg.png",
                VerticalOptions = LayoutOptions.Start,
                Aspect          = Aspect.Fill
            };

            ImageButton imgActivityBtn = new ImageButton()
            {
                Aspect = Aspect.Fill
            };
            imgActivityBtn.SetBinding(Image.SourceProperty, "ActivityBtnImageSource");
            imgActivityBtn.SetBinding(ImageButton.TappedCommandProperty, "ActivityButtonCommand");
            imgActivityBtn.SetBinding(ImageButton.IsEnabledProperty, "ActivityButtonEnabled", BindingMode.TwoWay);

            Label labelActivityName = new Label()
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 28,
                FontFamily = "Roboto"
            };
            labelActivityName.SetBinding(Label.TextProperty, "ActivityName", BindingMode.OneWay);

            Label labelActivityCategory = new Label()
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 20,
                FontFamily = "Roboto"
            };
            labelActivityCategory.SetBinding(Label.TextProperty, "Category", BindingMode.OneWay);

            Label labelStartedTime = new Label()
            {
                Text = "Started time",
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 16,
                FontFamily = "Roboto",
            };
            labelStartedTime.SetBinding(Label.IsVisibleProperty, "StartTimeVisible");
            labelStartedTime.SetBinding(Label.TextProperty, "StartTimeDisplay");

            Label labelElapsedTime = new Label()
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 28,
                FontFamily = "Roboto",
                TextColor  = Constants.TotalTimeElapsedColor
            };
            labelElapsedTime.SetBinding(Label.TextProperty, "TimeElapsed", BindingMode.OneWay);
            labelElapsedTime.SetBinding(Label.TextColorProperty, "TimeElapsedColor");

            Label labelHistory = new Label()
            {
                Text = "History",
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 16,
                FontFamily = "Roboto",
                TextColor  = Constants.HistoryTextColor
            };

            AppListView listViewHistory = new AppListView()
            {
                HasUnevenRows       = true,
                SeparatorVisibility = SeparatorVisibility.None,
                ItemTemplate        = new DataTemplate(typeof(ActivityPeriodCell))
            };
            listViewHistory.ItemSelected += (sender, e) => { ((ListView)sender).SelectedItem = null; };
            listViewHistory.SetBinding(AppListView.TapCommandProperty, "HistoryItemTappedCommand", BindingMode.OneWay);
            listViewHistory.SetBinding(ListView.ItemsSourceProperty, "History");
            #endregion
            //Methods goes -> X, Y, Width, Height
            //Add bg image
            #region BGImg
            relLayout.Children.Add(imgBg, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Y);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Height / 2);
            }));
            #endregion
            //Add the history label
            #region HistoryLabel
            relLayout.Children.Add(labelHistory, Constraint.RelativeToParent((p) =>
            {
                //X coord
                return(p.X + 12);
            }),
                                   Constraint.RelativeToView(imgBg, (p, s) =>
            {
                //Y coord
                return(s.Height + 4);
            }),
                                   Constraint.Constant(60),
                                   Constraint.Constant(21));
            #endregion
            //Add the labels
            #region ActivityLabel
            relLayout.Children.Add(labelActivityName, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Y + 24);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.Constant(36));
            #endregion
            #region ActivityCategoryLabel
            relLayout.Children.Add(labelActivityCategory, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToView(labelActivityName, (p, s) =>
            {
                return(s.Y + s.Height + 24);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.Constant(26));
            #endregion
            #region StartedTimeLabel
            relLayout.Children.Add(labelStartedTime, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToView(labelActivityCategory, (p, s) =>
            {
                return(s.Y + s.Height + 24);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.Constant(21));
            #endregion
            #region ElapsedTimeLabel
            relLayout.Children.Add(labelElapsedTime, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToView(labelStartedTime, (p, s) =>
            {
                return(s.Y + s.Height + 12);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.Constant(36));
            #endregion
            #region HistoryListView
            relLayout.Children.Add(listViewHistory, Constraint.RelativeToParent(p =>
            {
                return(p.X);
            }),
                                   Constraint.RelativeToView(imgBg, (p, s) =>
            {
                return(s.Height + 30);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                   Constraint.RelativeToView(imgBg, (p, s) =>
            {
                return(p.Height - s.Height - 30);
            }));
            #endregion
            //Add activity button
            #region ActivityButton
            int size = 128;
            relLayout.Children.Add(imgActivityBtn, Constraint.RelativeToView(imgBg, (p, s) =>
            {
                //X coord
                return(p.Width / 2 - size / 2);
            }),
                                   Constraint.RelativeToView(imgBg, (p, s) =>
            {
                //Y coord
                return(s.Height - 80);
            }),
                                   Constraint.Constant(size),
                                   Constraint.Constant(size));
            #endregion
            //Add the back button
            #region BackButton
            relLayout.Children.Add(imgBackBtn, Constraint.RelativeToView(imgBg, (p, s) =>
            {
                //X coord
                return(p.X + 10);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                //Y coord
                return(p.Y + 10);
            }),
                                   Constraint.Constant(32),
                                   Constraint.Constant(32));
            #endregion
            //Add the edit button
            #region EditButton
            int editBtnSize = 64;
            relLayout.Children.Add(imgEditActivityBtn, Constraint.RelativeToParent(p =>
            {
                //X coord
                return(p.Width - editBtnSize - 10);
            }),
                                   Constraint.RelativeToParent(p =>
            {
                //Y coord
                return(p.Y + 5);
            }),
                                   Constraint.Constant(editBtnSize),
                                   Constraint.Constant(editBtnSize));
            #endregion
        }