/// <summary>
        /// Construct alarm name row UI
        /// </summary>
        /// <param name="recod">AlarmRecord</param>
        /// <seealso cref="AlarmRecord">
        public AlarmEditName(AlarmRecord recod)
        {
            /// Fills horizontally
            HorizontalOptions = LayoutOptions.FillAndExpand;
            /// Fills vertically
            VerticalOptions = LayoutOptions.Start;
            HeightRequest   = 198;

            if (mainLabel == null)
            {
                mainLabel = new Label
                {
                    WidthRequest  = 720 - 32 * 2,
                    HeightRequest = 54,
                    Text          = "Alarm Name",
                    Style         = AlarmStyle.T023,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
            }

            /// Adds main label
            Children.Add(mainLabel,
                         Constraint.RelativeToParent((parent) => { return(32); }),
                         Constraint.RelativeToParent((parent) => { return(24); }));
            /// Creates entry
            mainEntry = new Entry()
            {
                WidthRequest  = 720 - (32 + 10) * 2,
                HeightRequest = 54,
                Text          = recod.AlarmName,
            };
            mainEntry.SetBinding(Entry.TextProperty, new Binding("AlarmName", BindingMode.Default, source: recod));

            /// Checks whether already set alarm name
            if (string.IsNullOrEmpty(AlarmModel.BindableAlarmRecord.AlarmName))
            {
                mainEntry.Placeholder = "Alarm";
            }
            else
            {
                mainEntry.Text = AlarmModel.BindableAlarmRecord.AlarmName;
            }

            /// Sets font size (DP base)
            mainEntry.FontSize = CommonStyle.GetDp(40);
            /// Adds to layout
            Children.Add(mainEntry,
                         Constraint.RelativeToView(mainLabel, (parent, sibling) => { return(sibling.X + 10); }),
                         Constraint.RelativeToView(mainLabel, (parent, sibling) => { return(sibling.Y + sibling.Height + 33); }));
        }
        /// <summary>
        /// Create UI layout that will be displayed at the top of the ListView
        /// </summary>
        /// <returns>RelativeLayout</returns>
        private RelativeLayout CreateListViewHeader()
        {
            // The View for Header of ListView
            RelativeLayout headerLayout = new RelativeLayout
            {
                HeightRequest = 93
            };

            // Title label of ListView's header
            Label headerTitleLabel = new Label()
            {
                HorizontalOptions     = LayoutOptions.FillAndExpand,
                VerticalTextAlignment = TextAlignment.Center,
                Text      = "Select all",
                TextColor = Color.Black,
                FontSize  = 20,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(headerTitleLabel, FontWeight.Light);
            headerLayout.Children.Add(headerTitleLabel,
                                      Constraint.RelativeToParent((parent) =>
            {
                return(32 + 10);
            }),
                                      Constraint.RelativeToParent((parent) =>
            {
                return(22 + 93 - 72);
            }));

            // Switch to give an app user an opportunity to delete all data items of List
            deleteAllSwitch = new Switch
            {
                HorizontalOptions = LayoutOptions.End,
            };
            VisualAttributes.SetThemeStyle(deleteAllSwitch, "CheckBox");
            deleteAllSwitch.Toggled += DeleteAllSwitch_Toggled;
            headerLayout.Children.Add(deleteAllSwitch,
                                      Constraint.RelativeToParent((parent) =>
            {
                return(720 - 104);
            }),
                                      Constraint.RelativeToParent((parent) =>
            {
                return(22 + 93 - 72);
            }));
            return(headerLayout);
        }
        public CounterView(/*StackLayout parent, */ CounterType type)
        {
            type_ = type;

            if (type == CounterType.COUNTER_TYPE_STOPWATCH)
            {
                layout_ = new RelativeLayout
                {
                    Style = stopwatchLayoutStyle,
                };
                hmsLabel_ = new Label
                {
                    Style = stopwatchHMSLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(hmsLabel_, FontWeight.Thin);

                msLabel_ = new Label
                {
                    Style = stopwatchMSLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(msLabel_, FontWeight.Thin);
            }
            else
            {
                layout_ = new RelativeLayout
                {
                    Style = timerLayoutStyle,
                };
                hmsLabel_ = new Label
                {
                    Style = timerLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(hmsLabel_, FontWeight.Thin);
            }

            AddChildren();
        }
        /// <summary>
        /// Construct alarm tone row UI
        /// </summary>
        /// <param name="editType">type indicator</param>
        /// <seealso cref="AlarmToneTypes">
        public AlarmToneRow(AlarmToneTypes type)
        {
            /// Sets each row height to 120 according UX guide
            HeightRequest = 120;

            /// Checks type and set mainStr
            switch (type)
            {
            case AlarmToneTypes.AlarmMp3:
                mainStr = "alarm.mp3";
                break;

            case AlarmToneTypes.Default:
                mainStr = "Default";
                break;

            case AlarmToneTypes.RingtoneSdk:
                mainStr = "ringtone_sdk.mp3";
                break;

            default:
                mainStr = "";
                break;
            }

            /// If mainStr is not null, create a new main Label
            if (mainStr != null)
            {
                if (mainLabel == null)
                {
                    mainLabel = new Label
                    {
                        HeightRequest = 54,
                        Style         = AlarmStyle.T033,
                    };
                    // to meet To meet thin attribute for font, need to use custom feature
                    FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
                }

                /// Sets main Label with mainStr
                mainLabel.Text = mainStr;
                /// Add to layout
                Children.Add(mainLabel,
                             Constraint.RelativeToParent((parent) => { return(32); }),
                             Constraint.RelativeToParent((parent) => { return((120 - 72) / 2); }));
            }

            /// Create a new radio button for this row
            toneRadio = new RadioButton
            {
                Text          = type.ToString(),
                HeightRequest = 80,
                WidthRequest  = 80,
                /// Group name should be set same for all radio button group elements
                GroupName = "AlarmTone",
            };

            if (AlarmModel.BindableAlarmRecord.AlarmToneType == type)
            {
                toneRadio.IsSelected = true;
                oldValue             = newValue = type;
            }

            toneRadio.Selected += ToneRadio_Selected;

            Children.Add(toneRadio,
                         Constraint.RelativeToParent((parent) => (parent.X + parent.Width - (80 + 32))),
                         Constraint.RelativeToParent((parent) => { return((120 - 80) / 2); }));
        }
        /// <summary>
        /// RingPage UI for Timer
        /// title label, Hour/Minute/Second labels
        /// </summary>
        private void CreateRingLabels()
        {
            Label titleLabel = new Label
            {
                Text          = "Time is up",
                Style         = TimerStyle.ATO019,
                HeightRequest = 58,
                WidthRequest  = 400,
                //BackgroundColor = Color.Orange,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(titleLabel, FontWeight.Light);
            rLayout.Children.Add(titleLabel,
                                 Constraint.RelativeToParent((parent) => { return(160); }),
                                 Constraint.RelativeToParent((parent) => { return(241 - 58); }));

            // case: display H/M/S
            hLabel = new Label
            {
                Text      = "Hours",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(hLabel, FontWeight.Normal);
            rLayout.Children.Add(hLabel,
                                 Constraint.RelativeToParent((parent) => { return(50 + 18); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            mLabel = new Label
            {
                Text      = "Minutes",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(mLabel, FontWeight.Normal);
            rLayout.Children.Add(mLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 - 70); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            sLabel = new Label
            {
                Text      = "Seconds",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(sLabel, FontWeight.Normal);
            rLayout.Children.Add(sLabel,
                                 Constraint.RelativeToParent((parent) => { return(720 - 50 - 18 - 140); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            //case: display M/S
            _mLabel = new Label
            {
                Text  = "Minutes",
                Style = TimerStyle.ATO009,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(_mLabel, FontWeight.Normal);
            rLayout.Children.Add(_mLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 - 120 - 50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            _sLabel = new Label
            {
                Text  = "Seconds",
                Style = TimerStyle.ATO009,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(_sLabel, FontWeight.Normal);
            rLayout.Children.Add(_sLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 + 50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            counterview   = new CounterView(CounterType.COUNTER_TYPE_TIMER);
            counterLayout = counterview.GetCounterLayout();
            //counterLayout.BackgroundColor = Color.Lime;
            counterview.DisplayTime("00:00");
            rLayout.Children.Add(counterLayout,
                                 Constraint.RelativeToParent((parent) => { return(50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));

            minusImage = new Image
            {
                Source          = "timer/timer_ringing_minus.png",
                WidthRequest    = 36,
                HeightRequest   = 204,
                VerticalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("#FFFAFAFA"),
                IsVisible = false,
            };

            rLayout.Children.Add(minusImage,
                                 Constraint.RelativeToParent((parent) => { return(50 - 36); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));

            _minusImage = new Image
            {
                Source          = "timer/timer_ringing_minus.png",
                WidthRequest    = 36,
                HeightRequest   = 204,
                VerticalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("FFFAFAFA"),
            };

            rLayout.Children.Add(_minusImage,
                                 Constraint.RelativeToParent((parent) => { return(360 - 120 - 50 - 18 - 8 - 36); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));
        }
        /// <summary>
        /// RingPage UI for Alarm
        /// Alarm Name, AM/PM label, Date & Time label
        /// </summary>
        private void CreateAlarmInfo()
        {
            Label alarmTitleLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO006,
                HeightRequest         = 69,
                Text                  = _alarmRecord.AlarmName.Equals("") ? "Alarm" : _alarmRecord.AlarmName,
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(alarmTitleLabel, FontWeight.Light);

            Func <RelativeLayout, double> getAlarmTitleLabelWidth = (p) => alarmTitleLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(alarmTitleLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getAlarmTitleLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120); }));

            Label amLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO006,
                HeightRequest         = 69,
                Text                  = _alarmRecord.ScheduledDateTime.ToString("tt"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(amLabel, FontWeight.Light);

            Func <RelativeLayout, double> getAmLabelWidth = (p) => amLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(amLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getAmLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 100); }));

            Label timeLabel = new Label
            {
                Style         = Styles.AlarmStyle.ATO007,
                HeightRequest = 230,
                Text          = ((App)Application.Current).Is24hourFormat ?
                                _alarmRecord.ScheduledDateTime.ToString("HH:mm") :
                                _alarmRecord.ScheduledDateTime.ToString("hh:mm"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(timeLabel, FontWeight.Thin);

            Func <RelativeLayout, double> getTimeLabelWidth = (p) => timeLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(timeLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getTimeLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 127); }));

            Label dateLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO008,
                HeightRequest         = 64,
                Text                  = _alarmRecord.ScheduledDateTime.ToString("ddd, d MMMM"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(dateLabel, FontWeight.Light);

            Func <RelativeLayout, double> getDateLabelWidth = (p) => dateLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(dateLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getDateLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 127 + 230); }));
        }
        /// <summary>
        /// Draws alarm list
        /// </summary>
        /// <returns>Returns RelativeLayout</returns>
        protected virtual RelativeLayout Draw()
        {
            /// Need to get bindable context to assign list value
            AlarmRecord alarmData = (AlarmRecord)BindingContext;

            /// If binding context is null, can't proceed further action
            if (alarmData == null)
            {
                return(null);
            }

            alarmData.PrintProperty();

            /// Alarm item layout should be set if null
            if (alarmItemLayout == null)
            {
                // The layout of item cell
                alarmItemLayout = new RelativeLayout
                {
                    HeightRequest = 22 + 93 + 29,
                };

                // Time Label
                timeLabel = new Label()
                {
                    Text = (((App)Application.Current).Is24hourFormat) ?
                           alarmData.ScheduledDateTime.ToString("HH:mm") : alarmData.ScheduledDateTime.ToString("hh:mm"),
                    Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO001D : AlarmStyle.ATO001,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(timeLabel, FontWeight.Light);
                /// Style set for time label for normal case
                timeLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Time));
                /// Needs to set binding context for scheduled time
                timeLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.Time));
                // Added to layout
                alarmItemLayout.Children.Add(timeLabel,
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(22);
                }));

                // AM/PM Label
                amPmLabel = new Label()
                {
                    //the text of AM/PM label
                    Text = (((App)Application.Current).Is24hourFormat) ?
                           "" : alarmData.ScheduledDateTime.ToString("tt"),
                    Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO002D : AlarmStyle.ATO002,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(amPmLabel, FontWeight.Light);
                //amPmLabel.IsVisible = (((Tizen.App)Application.Current).Is24hourFormat) ? false : true;
                amPmLabel.SetBinding(Label.IsVisibleProperty, new Binding("AlarmDateFormat", BindingMode.Default, new DateFormatToVisibleConverter()));
                // Set style depending on alarm state
                amPmLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.AmPm));
                amPmLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.AmPm));
                // Added to layout
                alarmItemLayout.Children.Add(amPmLabel,
                                             Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.X + sibling.Width + 10),
                                             Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.Y + 36));

                // Repeat Image
                repeatImage = new Image
                {
                    Source        = "alarm/clock_ic_repeat.png",
                    WidthRequest  = 38,
                    HeightRequest = 38,
                };
                // Bind repeat Image's visibiliy to weekly repeating value
                repeatImage.SetBinding(Image.IsVisibleProperty, new Binding("Repeat", mode: BindingMode.Default));
                // Set repeat image's blending color on alarm state
                ImageAttributes.SetBlendColor(repeatImage, alarmData.AlarmState == AlarmStates.Inactive ? Color.FromHex("66000000") : Color.FromHex("FFFFFF"));
                repeatImage.SetBinding(ImageAttributes.BlendColorProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Repeat));
                // Added to layout
                alarmItemLayout.Children.Add(repeatImage,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93) - (43 + 43)));

                /// Alarm Name Label
                alamNameLabel = new Label();
                /// For alarm name label, to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(alamNameLabel, FontWeight.Normal);
                /// Bind alarm lable's style to alarm state
                alamNameLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Name));
                /// Bind label's text property to AlarmMode's AlarmName.
                alamNameLabel.SetBinding(Label.TextProperty, "AlarmName");
                // Update alarm name label's TranslationX property value according to repeat image's visibility
                alamNameLabel.SetBinding(Label.TranslationXProperty, new Binding("Repeat", BindingMode.OneWay, converter: new AlarmNameLabelPositionConverter()));
                // Bind alarm name label's visibility
                alamNameLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false));
                //alamNameLabel.Text = alarmData.AlarmName;
                // Added to relative layout
                alarmItemLayout.Children.Add(alamNameLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93 - (43 + 43))));

                /// WeekDays Label
                weekDaysLabel = new Label()
                {
                    FormattedText = alarmData.GetFormatted(alarmData.WeekFlag, alarmData.AlarmState < AlarmStates.Inactive ? true : false),
                    IsVisible     = !alarmData.IsVisibleDateLabel,
                    Style         = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO004D : AlarmStyle.ATO004,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(weekDaysLabel, FontWeight.Normal);
                /// Style set for time label for normal case
                weekDaysLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Weekly));
                /// Sets binding context for weekdays label
                weekDaysLabel.SetBinding(Label.FormattedTextProperty, new Binding("WeekdayRepeatText", BindingMode.Default));
                weekDaysLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false));
                /// Adds to relative layout
                alarmItemLayout.Children.Add(weekDaysLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93) - 43));

                // Date label
                // DateLabel is only visible when the alarm name is empty and repeat weekly is Never.
                dateLabel = new Label
                {
                    Text = alarmData.ScheduledDateTime.ToString("ddd, d MMM"),
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(dateLabel, FontWeight.Normal);
                dateLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), true));
                dateLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Date));
                alarmItemLayout.Children.Add(dateLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => 22));

                /// Switch object to represent that the alarm is active or not
                switchObj = new Switch
                {
                    HeightRequest = 72,
                    WidthRequest  = 72,
                    IsToggled     = alarmData.AlarmState == AlarmStates.Inactive ? false : true,
                };
                /// Bind IsToggled property to alarm state
                //switchObj.SetBinding(Switch.IsToggledProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.State));
                /// Adds to relative layout
                alarmItemLayout.Children.Add(switchObj,
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(720 - 104);
                }),
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(22 + 93 - 72);
                }));

                /// Adds an event
                switchObj.Toggled += (s, e) =>
                {
                    //Switch sObj = s as Switch;
                    ///// Needs valid parent to proceed
                    //if (sObj.Parent == null || sObj.Parent.Parent == null)
                    //{
                    //    return;
                    //}

                    ///// Need binding context to check state
                    //AlarmRecord am = (AlarmRecord)((AlarmListCell)sObj.Parent.Parent).BindingContext;
                    //if (am == null)
                    //{
                    //    return;
                    //}
                    AlarmRecord am = (AlarmRecord)BindingContext;
                    /// Modify state and re-draw it. Redraw must be called to redraw
                    //am.AlarmState = e.Value ? AlarmStates.Active : AlarmStates.Inactive;
                    if (e.Value)
                    {
                        AlarmModel.ReactivatelAlarm(am);
                    }
                    else
                    {
                        AlarmModel.DeactivatelAlarm(am);
                    }

                    AlarmModel.PrintAll("After switch is toggled...");
                };
            }
            else
            {
                switchObj.IsVisible = true;
            }

            return(alarmItemLayout);
        }
        /// <summary>
        /// Invoked when backbutton is pressed in AlarmEditPage
        /// If there's no changes,
        ///   just go back to AlarmListPage
        /// If there's changes,
        ///   a dialog will be shown and an app user gets an opportunity to save or discard them.
        /// </summary>
        /// <returns>bool</returns>
        protected override bool OnBackButtonPressed()
        {
            // Compare : initial AlarmRecord vs. current AlarmRecord
            bool same = AlarmModel.Compare(originalRecord, AlarmModel.BindableAlarmRecord);

            if (same)
            {
                ((App)Application.Current).floatingButton.Show();
                // Just go back to the previous screen
                return(base.OnBackButtonPressed());
            }
            else
            {
                if (dialog == null)
                {
                    // Cancel button
                    Button cancelButton = new Button
                    {
                        Text = "Cancel",
                    };
                    cancelButton.Clicked += CancelButton_Clicked;

                    // Discard button
                    Button discardButton = new Button
                    {
                        Text = "Discard"
                    };
                    discardButton.Clicked += DiscardButton_Clicked;

                    Label label = new Label
                    {
                        Text     = "All changes will be discarded.",
                        FontSize = 26,
                    };
                    FontFormat.SetFontWeight(label, FontWeight.Light);

                    StackLayout content = new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Margin            = new Thickness(20, 20, 20, 20),
                        Children          =
                        {
                            label
                        },
                        WidthRequest = 720,
                    };

                    // Dialog
                    dialog = new Dialog
                    {
                        HorizontalOption = LayoutOptions.Fill,
                        Title            = "Discard change",
                        Positive         = cancelButton,
                        Neutral          = discardButton,
                        Content          = content
                    };
                }

                dialog.Show();
                return(true);
            }
        }
Example #9
0
        /// <summary>
        /// Create a RelativeLayout for custom cells
        /// </summary>
        /// <returns>RelativeLayout</returns>
        private RelativeLayout CreateCityList()
        {
            if (cityListItemLayout == null)
            {
                cityListItemLayout = new RelativeLayout
                {
                    WidthRequest  = 720,
                    HeightRequest = 22 + 53 + 43 + 26,
                };

                timeLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO040,
                    WidthRequest            = 113,
                    HeightRequest           = 61, /*67*/// GUI GUIDE : 67
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(timeLabel, FontWeight.Light);
                timeLabel.SetBinding(Label.TextProperty, "CityTime");

                cityListItemLayout.Children.Add(timeLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17);
                }));

                amPmLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO041,
                    WidthRequest            = 52,
                    HeightRequest           = 40,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    //BackgroundColor = Color.Violet,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(amPmLabel, FontWeight.Medium);
                amPmLabel.SetBinding(Label.TextProperty, "CityAmPm");
                cityListItemLayout.Children.Add(amPmLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 113 + 8);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17 + 21);
                }));

                dateLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO042,
                    Text                    = "Wed, 20 Mar",
                    WidthRequest            = 173,
                    HeightRequest           = 40,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    //BackgroundColor = Color.Beige,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(dateLabel, FontWeight.Normal);
                dateLabel.SetBinding(Label.TextProperty, "CityDate");
                cityListItemLayout.Children.Add(dateLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17 + 61);
                }));

                citiesLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO043,
                    Text                    = "Beijing, China",
                    WidthRequest            = 405,
                    HeightRequest           = 53,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    //BackgroundColor = Color.SpringGreen,
                    LineBreakMode = LineBreakMode.TailTruncation,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(citiesLabel, FontWeight.Normal);
                citiesLabel.SetBinding(Label.TextProperty, "Cities");
                cityListItemLayout.Children.Add(citiesLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 173 + 82);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(22);
                }));

                relativeToLocalLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO044,
                    Text                    = "Same as local time",
                    WidthRequest            = 405,
                    HeightRequest           = 43,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    //BackgroundColor = Color.Black,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(relativeToLocalLabel, FontWeight.Normal);
                relativeToLocalLabel.SetBinding(Label.TextProperty, "RelativeToLocalCountry");
                cityListItemLayout.Children.Add(relativeToLocalLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 173 + 82);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(22 + 53);
                }));
            }

            return(cityListItemLayout);
        }
        /// <summary>
        /// CheckBox which users can check to indicate alarm repeat
        /// </summary>
        /// <param name="weekFlag">Week flag to indicate which week flag this row will show</param>
        /// <seealso cref="AlarmWeekFlag">
        public AlarmRepeatRow(AlarmWeekFlag weekFlag)
        {
            if (mainLabel != null)
            {
                return;
            }

            HeightRequest   = 120;
            VerticalOptions = LayoutOptions.Start;
            switch (weekFlag)
            {
            case AlarmWeekFlag.AllDays:
                mainStr = "Everyday";
                break;

            case AlarmWeekFlag.Monday:
                mainStr = "Every Monday";
                break;

            case AlarmWeekFlag.Tuesday:
                mainStr = "Every Tuesday";
                break;

            case AlarmWeekFlag.Wednesday:
                mainStr = "Every Wednesday";
                break;

            case AlarmWeekFlag.Thursday:
                mainStr = "Every Thursday";
                break;

            case AlarmWeekFlag.Friday:
                mainStr = "Every Friday";
                break;

            case AlarmWeekFlag.Saturday:
                mainStr = "Every Saturday";
                break;

            case AlarmWeekFlag.Sunday:
                mainStr = "Every Sunday";
                break;

            default:
                mainStr = "";
                break;
            }

            // day of the week to repeat
            mainLabel = new Label
            {
                HeightRequest = 54,
                Style         = AlarmStyle.T023,
                Text          = mainStr,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
            Children.Add(mainLabel,
                         Constraint.RelativeToParent((parent) => { return(32); }),
                         Constraint.RelativeToParent((parent) => { return((120 - 54) / 2); }));

            /// Adds CheckBox in this row
            weekdayCheckbox = new CheckBox
            {
                HeightRequest = 50,
                WidthRequest  = 50,
            };

            /// Checks whether this weekFlag indicates this CheckBox should turn on or not
            if (IsTurnOn(AlarmModel.BindableAlarmRecord.WeekFlag, weekFlag))
            {
                weekdayCheckbox.IsChecked = true;
            }

            /// When CheckBox is checked, needs to perform proper action based on circumstance
            /// For example if all days is checked out then all other CheckBox should also checked out
            weekdayCheckbox.Checked += (s, e) =>
            {
                CheckBox        c   = (CheckBox)s;
                var             obj = this.Parent;
                AlarmRepeatPage currentPage;
                while (true)
                {
                    if (obj.GetType() == typeof(AlarmRepeatPage))
                    {
                        currentPage = (AlarmRepeatPage)obj;
                        break;
                    }
                    else
                    {
                        obj = obj.Parent;
                    }
                }

                if (weekFlag != AlarmWeekFlag.AllDays)
                {
                    Update(AlarmModel.BindableAlarmRecord, weekFlag, e.Value); // closure warning (GC prevent)
                    if (e.Value == false)
                    {
                        ((AlarmRepeatRow)(currentPage.allDays.View)).weekdayCheckbox.IsChecked = false; // if any off turn off everyday
                    }
                    else
                    {
                        if (AlarmModel.BindableAlarmRecord.WeekFlag == AlarmWeekFlag.AllDays)
                        {
                            ((AlarmRepeatRow)(currentPage.allDays.View)).weekdayCheckbox.IsChecked = true; // if any off turn off everyday
                        }
                    }
                }
                else
                {
                    if (e.Value == false)
                    {
                        ((AlarmRepeatRow)(currentPage.mon.View)).weekdayCheckbox.IsChecked  = false;
                        ((AlarmRepeatRow)(currentPage.tue.View)).weekdayCheckbox.IsChecked  = false;
                        ((AlarmRepeatRow)(currentPage.wed.View)).weekdayCheckbox.IsChecked  = false;
                        ((AlarmRepeatRow)(currentPage.thur.View)).weekdayCheckbox.IsChecked = false;
                        ((AlarmRepeatRow)(currentPage.fri.View)).weekdayCheckbox.IsChecked  = false;
                        ((AlarmRepeatRow)(currentPage.sat.View)).weekdayCheckbox.IsChecked  = false;
                        ((AlarmRepeatRow)(currentPage.sun.View)).weekdayCheckbox.IsChecked  = false;
                    }
                    else
                    {
                        ((AlarmRepeatRow)(currentPage.mon.View)).weekdayCheckbox.IsChecked  = true;
                        ((AlarmRepeatRow)(currentPage.tue.View)).weekdayCheckbox.IsChecked  = true;
                        ((AlarmRepeatRow)(currentPage.wed.View)).weekdayCheckbox.IsChecked  = true;
                        ((AlarmRepeatRow)(currentPage.thur.View)).weekdayCheckbox.IsChecked = true;
                        ((AlarmRepeatRow)(currentPage.fri.View)).weekdayCheckbox.IsChecked  = true;
                        ((AlarmRepeatRow)(currentPage.sat.View)).weekdayCheckbox.IsChecked  = true;
                        ((AlarmRepeatRow)(currentPage.sun.View)).weekdayCheckbox.IsChecked  = true;
                    }
                }
            };

            Children.Add(weekdayCheckbox,
                         Constraint.RelativeToParent((parent) => (parent.X + parent.Width - (50 + 32))),
                         Constraint.RelativeToParent((parent) => { return((120 - 50) / 2); }));
        }
        /// <summary>
        /// Constructor for this class
        /// </summary>
        public AlarmEmptyPageLayout()
        {
            WidthRequest    = 720;
            VerticalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor = Color.White;
            /// set main label properties
            _mainLabel = new Label
            {
                WidthRequest            = 720 - 32 * 2,
                HeightRequest           = 54,
                Style                   = Styles.AlarmStyle.T020,
                TextColor               = Color.Gray,
                FontSize                = CommonStyle.GetDp(50),
                HorizontalTextAlignment = TextAlignment.Center,
            };
            FontFormat.SetFontWeight(_mainLabel, FontWeight.Light);

            /// setting sublabel properties
            _subLabel1 = new Label
            {
                WidthRequest            = 720 - 32 * 2,
                HeightRequest           = 43,
                HorizontalTextAlignment = TextAlignment.Center,
                //Style = Styles.AlarmStyle.T033,
                TextColor = Color.Gray,
                FontSize  = CommonStyle.GetDp(36),
            };
            FontFormat.SetFontWeight(_subLabel1, FontWeight.Light);

            /// setting sublabel properties
            _subLabel2 = new Label
            {
                WidthRequest            = 720 - 32 * 2,
                HeightRequest           = 43,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor = Color.Gray,
                FontSize  = CommonStyle.GetDp(36),
                //Style = Styles.AlarmStyle.T033
            };
            FontFormat.SetFontWeight(_subLabel2, FontWeight.Light);

            /// add to layout
            Children.Add(_mainLabel, Constraint.RelativeToParent((parent) =>
            {
                return(32);
            }),
                         Constraint.RelativeToParent((parent) =>
            {
                return((((VisualElement)Parent).Height - 194) / 2); /*((((VisualElement)Parent).Height - 254) - (54 + 54 + 43 + 43)) / 2*/;
            }));

            /// add to layout
            Children.Add(_subLabel1, Constraint.RelativeToView(_mainLabel, (parent, sibling) =>
            {
                return(sibling.X);
            }),
                         Constraint.RelativeToView(_mainLabel, (parent, sibling) =>
            {
                return(sibling.Y + sibling.Height + 54);
            }));
            /// add to layout
            Children.Add(_subLabel2, Constraint.RelativeToView(_subLabel1, (parent, sibling) =>
            {
                return(sibling.X);
            }),
                         Constraint.RelativeToView(_subLabel1, (parent, sibling) =>
            {
                return(sibling.Y + sibling.Height);
            }));
        }
        private void CreateEntries()
        {
            hoursEntry = new ExtendedEntry
            {
                Style = TimerStyle.timeSelectorEntryStyle,
                Text  = "00",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(hoursEntry, FontWeight.Thin);
            hoursEntry.TextChanged += OnTextChanged;
            hoursEntry.Completed   += OnCompleted;
            hoursEntry.Focused     += OnFocused;
            hoursEntry.Unfocused   += OnUnfocused;

            minutesEntry = new ExtendedEntry
            {
                Style = TimerStyle.timeSelectorEntryStyle,
                Text  = "00",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(minutesEntry, FontWeight.Thin);
            minutesEntry.TextChanged += OnTextChanged;
            minutesEntry.Completed   += OnCompleted;
            minutesEntry.Focused     += OnFocused;
            minutesEntry.Unfocused   += OnUnfocused;

            secondsEntry = new ExtendedEntry
            {
                Style = TimerStyle.timeSelectorEntryStyle,
                Text  = "00",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(secondsEntry, FontWeight.Thin);
            secondsEntry.TextChanged += OnTextChanged;
            secondsEntry.Completed   += OnCompleted;
            secondsEntry.Focused     += OnFocused;
            secondsEntry.Unfocused   += OnUnfocused;

            Label colonLabel1 = new Label
            {
                Style = TimerStyle.timeSelectorLabelStyle,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(colonLabel1, FontWeight.Thin);

            Label colonLabel2 = new Label
            {
                Style = TimerStyle.timeSelectorLabelStyle,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(colonLabel2, FontWeight.Thin);

            timerLayout = new RelativeLayout
            {
                //Margin = new Thickness(0, /*364*//*236*/, 0, 0),
                WidthRequest  = 620,
                HeightRequest = 204,
                //HorizontalOptions = LayoutOptions.FillAndExpand,
                //BackgroundColor = Color.Silver,
            };

            timerLayout.Children.Add(hoursEntry,
                                     Constraint.RelativeToParent((parent) => { return(0); }),
                                     Constraint.RelativeToParent((parent) => { return(0); }));

            timerLayout.Children.Add(colonLabel1,
                                     Constraint.RelativeToParent((parent) => { return(190); }),
                                     Constraint.RelativeToParent((parent) => { return(0); }));

            timerLayout.Children.Add(minutesEntry,
                                     Constraint.RelativeToParent((parent) => { return(190 + 25); }),
                                     Constraint.RelativeToParent((parent) => { return(0); }));

            timerLayout.Children.Add(colonLabel2,
                                     Constraint.RelativeToParent((parent) => { return(190 + 25 + 190); }),
                                     Constraint.RelativeToParent((parent) => { return(0); }));

            timerLayout.Children.Add(secondsEntry,
                                     Constraint.RelativeToParent((parent) => { return(190 + 25 + 190 + 25); }),
                                     Constraint.RelativeToParent((parent) => { return(0); }));

            // time selection entries
            topRelativeLayout.Children.Add(timerLayout,
                                           Constraint.RelativeToParent((parent) => { return(0); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20 + 76 + 4); }));
        }
        void CreateSelectors()
        {
            hoursLabel = new Label
            {
                Style = TimerStyle.timelabelStyle,
                Text  = "Hours",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(hoursLabel, FontWeight.Normal);

            minutesLabel = new Label
            {
                Style = TimerStyle.timelabelStyle,
                Text  = "Minutes",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(minutesLabel, FontWeight.Normal);

            secondsLabel = new Label
            {
                Style = TimerStyle.timelabelStyle,
                Text  = "Seconds",
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(secondsLabel, FontWeight.Normal);

            CreateEntries();

            hourIncButton = new Button
            {
                Style = TimerStyle.arrowUpButtonStyle,
            };
            hourIncButton.Clicked += OnButtonClicked;

            hourDecButton = new Button
            {
                Style = TimerStyle.arrowDownButtonStyle,
            };
            hourDecButton.Clicked += OnButtonClicked;

            minIncButton = new Button
            {
                Style = TimerStyle.arrowUpButtonStyle,
            };
            minIncButton.Clicked += OnButtonClicked;

            minDecButton = new Button
            {
                Style = TimerStyle.arrowDownButtonStyle,
            };
            minDecButton.Clicked += OnButtonClicked;

            secIncButton = new Button
            {
                Style = TimerStyle.arrowUpButtonStyle,
            };
            secIncButton.Clicked += OnButtonClicked;

            secDecButton = new Button
            {
                Style = TimerStyle.arrowDownButtonStyle,
            };
            secDecButton.Clicked += OnButtonClicked;

            // TODO CHECK : GUI GUIDE  (additionally, X position -= 26)
            topRelativeLayout.Children.Add(hoursLabel,
                                           Constraint.RelativeToParent((parent) => { return(20 /*46*/); }),
                                           Constraint.RelativeToParent((parent) => { return(0); }));

            topRelativeLayout.Children.Add(minutesLabel,
                                           Constraint.RelativeToParent((parent) => { return(46 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(0); }));

            // TODO CHECK : GUI GUIDE  (additionally, X position += 26)
            topRelativeLayout.Children.Add(secondsLabel,
                                           Constraint.RelativeToParent((parent) => { return(26 + 46 + 146 + 45 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(0); }));

            // time-increasing buttons
            topRelativeLayout.Children.Add(hourIncButton,
                                           Constraint.RelativeToParent((parent) => { return(20); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20); }));

            topRelativeLayout.Children.Add(minIncButton,
                                           Constraint.RelativeToParent((parent) => { return(46 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20); }));

            topRelativeLayout.Children.Add(secIncButton,
                                           Constraint.RelativeToParent((parent) => { return(26 + 46 + 146 + 45 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20); }));

            // time-decreasing buttons
            // TODO CHECK : GUI GUIDE  (additionally, X position -= 26)
            topRelativeLayout.Children.Add(hourDecButton,
                                           Constraint.RelativeToParent((parent) => { return(20); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20 + 76 + 4 + 204 + 4); }));

            topRelativeLayout.Children.Add(minDecButton,
                                           Constraint.RelativeToParent((parent) => { return(46 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20 + 76 + 4 + 204 + 4); }));

            // TODO CHECK : GUI GUIDE  (additionally, X position += 26)
            topRelativeLayout.Children.Add(secDecButton,
                                           Constraint.RelativeToParent((parent) => { return(26 + 46 + 146 + 45 + 146 + 45); }),
                                           Constraint.RelativeToParent((parent) => { return(42 + 20 + 76 + 4 + 204 + 4); }));
        }
            private StackLayout CreateWatchList()
            {
                var listLayout = new RelativeLayout
                {
                    WidthRequest  = 720,
                    HeightRequest = 360
                };

                // Create label of index
                Label lapNoLabel = new Label
                {
                    Margin        = new Thickness(32, 0, 0, 0),
                    WidthRequest  = 70,
                    HeightRequest = 120,
                    //HorizontalOptions = LayoutOptions.Center,
                    //VerticalOptions = LayoutOptions.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    TextColor = Color.Black,
                    //BackgroundColor = Color.Pink,
                    FontSize = CommonStyle.GetDp(42),
                };

                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(lapNoLabel, FontWeight.Light);
                lapNoLabel.SetBinding(Label.TextProperty, "No");
                // Add the labelIndex to listLayout
                listLayout.Children.Add(lapNoLabel,
                                        Constraint.RelativeToParent((parent) => { return(0); }),
                                        Constraint.RelativeToParent((parent) => { return(0); })); /*parent.Y + (parent.Height - 120) / 2*/

                // Create label of start time
                Label labelStart = new Label
                {
                    Margin        = new Thickness(90 /*130*/, 0, 0, 0),
                    WidthRequest  = 210 /*190*/,
                    HeightRequest = 120,
                    //HorizontalOptions = LayoutOptions.Center,
                    //VerticalOptions = LayoutOptions.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.End,
                    TextColor = Color.Black,
                    //BackgroundColor = Color.Lime,
                    FontSize = CommonStyle.GetDp(42),
                };

                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(labelStart, FontWeight.Light);
                labelStart.SetBinding(Label.TextProperty, "SplitTime");
                // Add the labelStart to listLayout
                listLayout.Children.Add(labelStart,
                                        Constraint.RelativeToView(lapNoLabel, (parent, sibling) => { return(sibling.X + sibling.Width); }),
                                        Constraint.RelativeToView(lapNoLabel, (parent, sibling) => { return(sibling.Y + (sibling.Height - 120) / 2); }));

                // Create label of time period
                Label labelPeriod = new Label
                {
                    Margin        = new Thickness(76, 0, 0, 0),
                    WidthRequest  = 210 /*190*/,
                    HeightRequest = 120,
                    //HorizontalOptions = LayoutOptions.Center,
                    //VerticalOptions = LayoutOptions.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.End,
                    TextColor = Color.FromHex("0000AA"),
                    //BackgroundColor = Color.Silver,
                    FontSize = CommonStyle.GetDp(42),
                };

                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(labelPeriod, FontWeight.Light);
                labelPeriod.SetBinding(Label.TextProperty, "LapTime");
                // Add the labelPeriod to listLayout
                listLayout.Children.Add(labelPeriod,
                                        Constraint.RelativeToView(labelStart, (parent, sibling) => { return(sibling.X + sibling.Width); }),
                                        Constraint.RelativeToView(lapNoLabel, (parent, sibling) => { return(sibling.Y + (sibling.Height - 120) / 2); }));

                return(new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Children =
                    {
                        listLayout
                    }
                });
            }
        /// <summary>
        /// Constructor for this class.
        /// Place UI controls and text according to given alarm type
        /// </summary>
        /// <param name="type">The alarm type to show in this row</param>
        /// <seealso cref="AlarmTypes">
        public AlarmTypeRow(AlarmTypes type)
        {
            HeightRequest = 120;
            switch (type)
            {
            case AlarmTypes.Sound:
                mainStr = "Sound";
                break;

            case AlarmTypes.Vibration:
                mainStr = "Vibration";
                break;

            case AlarmTypes.SoundVibration:
                mainStr = "Vibration and sound";
                break;

            default:
                mainStr = "";
                break;
            }

            if (mainStr != null)
            {
                if (mainLabel == null)
                {
                    mainLabel = new Label
                    {
                        HeightRequest = 54,
                        Style         = AlarmStyle.T033,
                        Text          = mainStr,
                    };
                    // to meet To meet thin attribute for font, need to use custom feature
                    FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
                }

                Children.Add(mainLabel,
                             Constraint.RelativeToParent((parent) => { return(32); }),
                             Constraint.RelativeToParent((parent) => { return((120 - 72) / 2); }));
            }

            typeRadio = new RadioButton
            {
                Text          = type.ToString(),
                GroupName     = "AlarmType",
                HeightRequest = 80,
                WidthRequest  = 80,
            };

            if (AlarmModel.BindableAlarmRecord.AlarmType == type)
            {
                typeRadio.IsSelected = true;
                oldValue             = newValue = type;
            }

            typeRadio.Selected += TypeRadio_Selected;

            Children.Add(typeRadio,
                         Constraint.RelativeToParent((parent) => (parent.X + parent.Width - (80 + 32))),
                         Constraint.RelativeToParent((parent) => { return((120 - 80) / 2); }));
        }
Example #16
0
        /// <summary>
        /// Make UI for presenting details for timezone
        /// Time / AM or PM / relative time difference / principal cities
        /// </summary>
        private void CreateTimezoenDetails()
        {
            timeLabel = new Label
            {
                Text              = "7:50",
                Style             = Styles.WorldclockStyle.ATO017,
                WidthRequest      = 164,
                HeightRequest     = 94,
                HorizontalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.Coral,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(timeLabel, FontWeight.Thin);
            timeLabel.SetBinding(Label.TextProperty, new Binding("CityTime", mode: BindingMode.OneWay, source: CityRecordUtility.detail));

            amLabel = new Label
            {
                Text              = "a.m.",
                Style             = Styles.WorldclockStyle.ATO018,
                WidthRequest      = 70,
                HeightRequest     = 48,
                HorizontalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.BurlyWood,
                Margin = new Thickness(12, 36, 20, 10),
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(amLabel, FontWeight.Normal);
            amLabel.SetBinding(Label.TextProperty, new Binding("CityAmPm", mode: BindingMode.OneWay, source: CityRecordUtility.detail));

            relativeToLocalLabel = new Label
            {
                Text              = "1h behind",
                Style             = Styles.WorldclockStyle.ATO018,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest     = 48,
                //BackgroundColor = Color.Pink,
                Margin = new Thickness(0, 36, 0, 10),
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(relativeToLocalLabel, FontWeight.Normal);
            relativeToLocalLabel.SetBinding(Label.TextProperty, new Binding("RelativeToLocalCountry", mode: BindingMode.OneWay, source: CityRecordUtility.detail));

            timezoneDetailFirstLineLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                Spacing           = 0,
                HeightRequest     = 94,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("#22dd22"),
                Children =
                {
                    timeLabel,
                    amLabel,
                    relativeToLocalLabel
                }
            };
            StackLayout tmpStack = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Spacing           = 0,
                HeightRequest     = 94,
                WidthRequest      = 720,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("#aa448b"),
                Children =
                {
                    timezoneDetailFirstLineLayout
                }
            };

            mapLayout.Children.Add(tmpStack,
                                   Constraint.RelativeToParent((parent) => { return(0); }),
                                   Constraint.RelativeToParent((parent) => { return(17 + 406 + 50); }));

            // principal cities in Timezone detail area
            citiesLabel = new Label
            {
                Text          = "Beijing, Denpasar, Guangzhou, Haikou",
                Style         = Styles.WorldclockStyle.ATO016,
                WidthRequest  = 720 - 16 - 16,
                HeightRequest = 51,
                LineBreakMode = LineBreakMode.TailTruncation,
                //BackgroundColor = Color.Blue,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(citiesLabel, FontWeight.Normal);
            citiesLabel.SetBinding(Label.TextProperty, new Binding(path: "Cities", mode: BindingMode.OneWay, source: CityRecordUtility.detail));
            mapLayout.Children.Add(citiesLabel,
                                   Constraint.RelativeToParent((parent) => { return(16); }),
                                   Constraint.RelativeToParent((parent) => { return(17 + 406 + 50 + 94); }));
        }