Пример #1
0
 /// <summary>
 /// Invoked when "Delete" more menu is choosed
 /// </summary>
 /// <param name="menu">string</param>
 private void ShowDeletePage(string menu)
 {
     // Make MoreMenuDialog invisible
     dialog.Hide();
     // Make WorldclockDeletePage visible
     Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.DeletePage), false);
 }
Пример #2
0
        /// <summary>
        /// Constructor for Alarm list ui class
        /// </summary>
        public AlarmListUI()
        {
            /// Creates alarm custom cell template based on AlarmListCell
            var customCell = new DataTemplate(typeof(AlarmListCell));

            /// AlarmList view property setting
            alarmListView = new ListView
            {
                /// Sets vertical option to fill
                VerticalOptions = LayoutOptions.FillAndExpand,
                /// All rows are in even size
                HasUnevenRows = false,
                /// Sets item source by Observable alarm list
                ItemsSource = AlarmModel.ObservableAlarmList,
                /// Sets template to customCell object
                ItemTemplate = customCell
            };

            /// Command to trigger page push (AlarmEditPage)
            Command = new Command(async(o) =>
            {
                /// Needs to await for page push
                await Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.EditPage, o));
            });

            /// When an item is selected, execute a command if command is set.
            alarmListView.ItemSelected += (s, e) =>
            {
                /// skips for no selected item case
                if (e.SelectedItem == null)
                {
                    // Todo: handle deselect case
                    return;
                }

                /// checks selected item
                AlarmRecord alarm = e.SelectedItem as AlarmRecord;
                /// Deselects first
                ((ListView)s).SelectedItem = null; // de-select the row
                /// Executes commands if it has beens set.
                if (Command != null && Command.CanExecute(null))
                {
                    Command.Execute(alarm);
                }
            };

            /// Adds alarmListView to this StackLayout
            Children.Add(alarmListView);
        }
Пример #3
0
        /// <summary>
        /// Called when the floating button has been clicked
        /// Show a page for editing an alarm
        /// When the floating button is clicked (new alarm request), new alarm will be created and call
        /// Alarm Edit Page with the created alarm record
        /// </summary>
        /// <param name="sender">floating button object</param>
        /// <seealso cref="System.object">
        /// <param name="e">Event argument for event of floating button.</param>
        /// <seealso cref="System.EventArgs">
        public void OnFloatingButtonClicked(object sender, EventArgs e)
        {
            if (AlarmModel.ObservableAlarmList.Count >= MAX_ITEMS_LIMIT)
            {
                Toast.DisplayText("Maximum number of alarms(" + MAX_ITEMS_LIMIT + ") reached.");
                return;
            }

            /// Creates default alarm record
            AlarmRecord defaultAlarmRecord = new AlarmRecord();

            defaultAlarmRecord.SetDefault();
            /// Call via alarm page controller which instantiates page once
            Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.EditPage, defaultAlarmRecord), false);
        }
Пример #4
0
        /// <summary>
        /// Create AlarmEditPage's UI
        /// </summary>
        private void Draw()
        {
            // Hide navigation bar (title and buttons)
            NavigationPage.SetHasNavigationBar(this, false);

            // Create TitleBar
            titleBar = new TitleBar();
            titleBar.LeftButton.Text      = "CANCEL";
            titleBar.RightButton.Text     = "DONE";
            titleBar.TitleLabel.Text      = "Create";
            titleBar.LeftButton.Clicked  += CANCEL_Clicked;
            titleBar.RightButton.Clicked += DONE_Clicked;

            // Create time edit cell
            editTimePickerCell = new AlarmEditTimePickerCell(AlarmModel.BindableAlarmRecord);
            editTimePickerCell.SetBinding(AlarmEditTimePickerCell.TimeProperty, new Binding("ScheduledDateTime", BindingMode.Default, source: AlarmModel.BindableAlarmRecord));

            // Create repeat edit cell
            TextCell repeatTextCell = new TextCell
            {
                Text    = "Repeat weekly",
                Detail  = "Never",
                Command = new Command(async() =>
                {
                    await Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.RepeatPage));
                })
            };

            repeatTextCell.SetBinding(TextCell.DetailProperty, new Binding("WeekFlag", mode: BindingMode.Default, converter: new AlarmValueConverter(), source: AlarmModel.BindableAlarmRecord));

            // Create alarm type cell
            TextCell typeTextCell = new TextCell
            {
                Text    = "Alarm type",
                Detail  = "Sound",
                Command = new Command(async() =>
                {
                    await Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.TypePage));
                })
            };

            typeTextCell.SetBinding(TextCell.DetailProperty, new Binding("AlarmType", mode: BindingMode.Default, converter: new AlarmValueConverter(), source: AlarmModel.BindableAlarmRecord));

            // Create sound type cell
            AlarmEditSliderCell soundVolumeCell = new AlarmEditSliderCell(AlarmModel.BindableAlarmRecord);

            // Create tone selection cell
            TextCell toneTextCell = new TextCell
            {
                Text    = "Alarm tone",
                Detail  = "Default",
                Command = new Command(async() =>
                {
                    await Navigation.PushAsync(AlarmPageController.GetInstance(AlarmPages.TonePage));
                })
            };

            toneTextCell.SetBinding(TextCell.DetailProperty, new Binding("AlarmToneType", mode: BindingMode.Default, converter: new AlarmValueConverter(), source: AlarmModel.BindableAlarmRecord));

            // Create snooze setting cell
            MultilineCell snoozeMultilineCell = new MultilineCell
            {
                Text           = "Snooze",
                Multiline      = "Sound the alarm 3 times, at 5-minute intervals.",
                IsCheckVisible = true,
                IsChecked      = true,
            };

            snoozeMultilineCell.SetBinding(MultilineCell.IsCheckedProperty, new Binding("Snooze", BindingMode.TwoWay, source: AlarmModel.BindableAlarmRecord));

            // Create name setting cell
            nameCell = new AlarmEditNameCell(AlarmModel.BindableAlarmRecord);

            // TableRoot
            TableRoot root = new TableRoot()
            {
                new TableSection()
                {
                    editTimePickerCell,
                    repeatTextCell,
                    typeTextCell,
                    soundVolumeCell,
                    toneTextCell,
                    snoozeMultilineCell,
                    nameCell,
                }
            };

            TableView alarmEditTable = new TableView
            {
                Root          = root,
                HasUnevenRows = true,
            };

            // Main layout for AlarmEditPage
            StackLayout mainLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BindingContext    = AlarmModel.BindableAlarmRecord,
                Children          =
                {
                    titleBar,
                    alarmEditTable
                }
            };

            Content = mainLayout;
        }
 // Constructor
 public AlarmDeleteListCell() : base()
 {
     // Set current page
     currentPage = ((AlarmDeletePage)AlarmPageController.GetInstance(AlarmPages.DeletePage));
 }