/// <summary>
        /// Invoked when the switch is toggled or untoggled.
        /// </summary>
        /// <param name="sender">Checkbox-style Switch</param>
        /// <param name="e">ToggledEventArgs</param>
        private void ItemSwitch_Toggled(object sender, ToggledEventArgs e)
        {
            if (currentPage == null)
            {
                int currentIndex = (App.Current.MainPage as NavigationPage).Navigation.NavigationStack.Count - 1;
                currentPage = (WorldclockDeletePage)(App.Current.MainPage as NavigationPage).Navigation.NavigationStack[currentIndex];
            }

            // In case that it's called by deleteAllSwitch, there's nothing to do anymore.
            if (currentPage.OnAlldeleted == SwitchType.WholeSwitch)
            {
                return;
            }

            currentPage.OnAlldeleted = SwitchType.SingleSwitch;
            // It's called by turning on/off the "CheckBoxSwitch" switch

            // In case that Switch in ListView's ItemCell is off,
            if (!e.Value && currentPage.deleteAllSwitch.IsToggled)
            {
                currentPage.deleteAllSwitch.IsToggled = false;
            }

            UpdateTitle();
            // In case that Switch is on
            // Need to check all data items' switches are all on
            // If so, deleteAllSwitch switch should be toggled.
            if (e.Value && (currentPage.selectedItems == ((WorldclockInfo)currentPage.BindingContext).CityRecordList.Count))
            {
                currentPage.deleteAllSwitch.IsToggled = true;
            }

            currentPage.OnAlldeleted = SwitchType.None;
        }
Example #2
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(WorldclockDeletePage.GetInstance(App.ClockInfo), false);
 }
 /// <summary>
 /// Return Worldclock delete page
 /// </summary>
 /// <param name="_info">WorldclockInfo</param>
 /// <returns>WorldclockDeletePage</returns>
 public static WorldclockDeletePage GetInstance(WorldclockInfo _info)
 {
     return(DeletePage ?? (DeletePage = new WorldclockDeletePage(_info)));
 }