public override void ViewDidLoad() { base.ViewDidLoad(); bool state = (Manager.Singletone.ftpThread != null && Manager.Singletone.ftpThread.IsAlive); //NSUserDefaults.StandardUserDefaults.BoolForKey("FTPServer"); FTPSwitcher.SetState(state, false); FTPBackgroundSwitcher.SetState(NSUserDefaults.StandardUserDefaults.BoolForKey(UserDefaultsKeys.FTPServerBackground), false); BackgroundEnabler.SetState(NSUserDefaults.StandardUserDefaults.BoolForKey(UserDefaultsKeys.BackgroundModeEnabled), false); DHTSwitcher.SetState(NSUserDefaults.StandardUserDefaults.BoolForKey(UserDefaultsKeys.DHTEnabled), false); BackgroundTypeButton.SetTitle(((BackgroundTypes)(int)NSUserDefaults.StandardUserDefaults.IntForKey(UserDefaultsKeys.BackgroundModeType)).ToString(), UIControlState.Normal); CheckUpdate(); }
partial void BackgroundTypeButtonAction(UIButton sender) { var controller = UIAlertController.Create("Background type", "Current selection: " + BackgroundTypeButton.TitleLabel.Text, UIAlertControllerStyle.ActionSheet); var music = UIAlertAction.Create(GetBackgroundTypeTitle(BackgroundTypes.Music), UIAlertActionStyle.Default, delegate { var musicController = UIAlertController.Create("Play music mode", "This mode is based on playing empty music file, which cannot be stopped by another apps.\nHowever, there isn't any indication that background mode works.", UIAlertControllerStyle.Alert); var enable = UIAlertAction.Create("Enable", UIAlertActionStyle.Default, delegate { NSUserDefaults.StandardUserDefaults.SetInt((int)BackgroundTypes.Music, UserDefaultsKeys.BackgroundModeType); BackgroundTypeButton.SetTitle(BackgroundTypes.Music.ToString(), UIControlState.Normal); }); var cancel = UIAlertAction.Create("Close", UIAlertActionStyle.Cancel, null); musicController.AddAction(enable); musicController.AddAction(cancel); PresentViewController(musicController, true, null); }); var microphone = UIAlertAction.Create(GetBackgroundTypeTitle(BackgroundTypes.Microphone), UIAlertActionStyle.Default, delegate { var microphoneController = UIAlertController.Create("Record on microphone mode", "This mode is based on recording audio into temp file, which will be removed on stop. Has an indication in the form of a red status bar\nLimitation: it can be interrupted by any music or video from another app.\n!UNSTABLE!\nMAY NOT WORK FROM THE FIRST TRY, OPEN AND CLOSE THIS APP UNTIL STATUS BAR BECOMES RED", UIAlertControllerStyle.Alert); var enable = UIAlertAction.Create("Enable", UIAlertActionStyle.Destructive, delegate { NSUserDefaults.StandardUserDefaults.SetInt((int)BackgroundTypes.Microphone, UserDefaultsKeys.BackgroundModeType); BackgroundTypeButton.SetTitle(BackgroundTypes.Microphone.ToString(), UIControlState.Normal); }); var cancel = UIAlertAction.Create("Close", UIAlertActionStyle.Cancel, null); microphoneController.AddAction(enable); microphoneController.AddAction(cancel); PresentViewController(microphoneController, true, null); }); var close = UIAlertAction.Create("Close", UIAlertActionStyle.Cancel, null); controller.AddAction(music); controller.AddAction(microphone); controller.AddAction(close); if (controller.PopoverPresentationController != null) { controller.PopoverPresentationController.SourceView = sender; controller.PopoverPresentationController.SourceRect = sender.Bounds; } PresentViewController(controller, true, null); }