public ContainerController() { Title = "Pick a color!"; View.BackgroundColor = UIColor.FromRGB(0.3f, 0.8f, 0.3f); var pickAColorBtn = UIButton.FromType(UIButtonType.RoundedRect); pickAColorBtn.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 50, UIScreen.MainScreen.Bounds.Height / 2 - 22, 100, 44); pickAColorBtn.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; pickAColorBtn.SetTitle("Pick a color!", UIControlState.Normal); pickAColorBtn.TouchUpInside += async delegate { var alert = new UIAlertView("Hi", "hi there", null, null); // get a color from the user var color = await ColorPickerViewController.PresentAsync(NavigationController, "Pick a color!", View.BackgroundColor); // changethe background View.BackgroundColor = color; // set the title to the hex value nfloat red, green, blue, alpha; color.GetRGBA(out red, out green, out blue, out alpha); Title = string.Format("#{0:X2}{1:X2}{2:X2}", (int)(red * 255), (int)(green * 255), (int)(blue * 255)); }; View.AddSubview(pickAColorBtn); }
private static ColorPickerViewController MakePicker(SubMenu subMenu, string id, string name, string description, string hex, bool setter = true) { Color col = Color.red; ColorUtility.TryParseHtmlString(config.GetString("Colors", id, hex, true), out col); colorMap[id] = col; ColorPickerViewController newPicker = subMenu.AddColorPicker(name, description, colorMap[id]); newPicker.GetValue += delegate { return(colorMap[id]); }; if (setter) { newPicker.SetValue += delegate(Color value) { string newHex = "#" + ColorUtility.ToHtmlStringRGB(value); hexMap[hex] = newHex; config.SetString("Colors", id, newHex); }; } return(newPicker); }
private void DrawColorButtonPressed(object sender, EventArgs args) { ColorPickerViewController.Present( NavigationController, "Pick a color!", DrawColor, color => { DrawColor = color ?? UIColor.Black; }); }
void pickAColorBtn_HandleTouchUpInside(object sender, EventArgs e) { picker = new ColorPickerViewController(); picker.ColorPicked += HandleColorPicked; picker.Title = "Pick a color!"; UINavigationController pickerNav = new UINavigationController(picker); pickerNav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done); picker.NavigationItem.RightBarButtonItem = doneBtn; doneBtn.Clicked += doneBtn_HandleClicked; nav.PresentModalViewController(pickerNav, true); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. _colorPicker = new ColorPickerViewController(); _colorPicker.ColorPicked += HandleColorPicked; _pickerNav = new UINavigationController(_colorPicker); _pickerNav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White); _activityIndicator.Color = Util.TB_BLUE_COLOR; var doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done); _colorPicker.NavigationItem.RightBarButtonItem = doneBtn; doneBtn.Clicked += HandlePickerDismissed; MainTitleTbox.ShouldReturn += DismissKeyboardAndSave; EdgesForExtendedLayout = UIRectEdge.None; ActionTbox.InputAccessoryView = ModifierToolbar; ModifierToolbarBtn.Title = "More".Localize(); ModifierKeysView.Frame = new CoreGraphics.CGRect(0, 0, Util.ScreenWidth, Util.iPadKeyboardHeight); ActionTbox.AutocorrectionType = UITextAutocorrectionType.No; var item = ActionTbox.InputAssistantItem; item.LeadingBarButtonGroups = null; item.TrailingBarButtonGroups = null; CancelBarBtn.Clicked += (object sender, EventArgs e) => { OnDismissViewController(false, false); }; HelpToolbarBtn.Clicked += (sender, e) => { InvokeOnMainThread(() => { var controller = new SFSafariViewController(new NSUrl("http://www.timelabs.io/touchboard")); this.PresentViewController(controller, true, null); }); }; UIBarButtonItem saveBarbtn = new UIBarButtonItem("Save".Localize(), UIBarButtonItemStyle.Done, (s, e) => { if (Save()) { OnDismissViewController(true, false); } else { new UIAlertView("Error".Localize(), "Please check the action".Localize(), null, "Ok".Localize()).Show(); } }); UIBarButtonItem saveApplyAllBarButton = new UIBarButtonItem("Apply to All -".Localize(), UIBarButtonItemStyle.Done, (s, e) => { UIAlertView alert = new UIAlertView("Warning".Localize(), "This will apply the current style to every key".Localize(), null, "Cancel".Localize(), "Apply".Localize()); alert.Show(); alert.Clicked += (object s1, UIButtonEventArgs e1) => { if (e1.ButtonIndex == 1) { if (Save()) { OnDismissViewController(true, true); } else { new UIAlertView("Error".Localize(), "Please check the action".Localize(), null, "Ok".Localize()).Show(); } } }; }); UINavigationItem navItem = new UINavigationItem("Customize".Localize()); navItem.RightBarButtonItems = new UIBarButtonItem[] { saveBarbtn, saveApplyAllBarButton }; navItem.LeftBarButtonItem = CancelBarBtn; navItem.RightBarButtonItem.TintColor = UIColor.White; NavBar.Items = new UINavigationItem[] { navItem }; NavBar.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = UIColor.White }; TitleColorBtn.Tag = (int)ColorSelection.TITLE; SubtitleColorBtn.Tag = (int)ColorSelection.SUBTITLE; BackgroundColorBtn.Tag = (int)ColorSelection.BACKGROUND; TitleSelColorBtn.Tag = (int)ColorSelection.TITLE_SEL; SubtitleSelColorBtn.Tag = (int)ColorSelection.SUBTITLE_SEL; BackroundSelColorBtn.Tag = (int)ColorSelection.BACKGROUND_SEL; CustomizeColorButton(TitleColorBtn); CustomizeColorButton(SubtitleColorBtn); CustomizeColorButton(BackgroundColorBtn); CustomizeColorButton(TitleSelColorBtn); CustomizeColorButton(SubtitleSelColorBtn); CustomizeColorButton(BackroundSelColorBtn); CustomizeColorButton(SelectedIconBtn); CustomizeColorButton(DefaultIconBtn); SelectedIconBtn.BackgroundColor = UIColor.Clear; DefaultIconBtn.BackgroundColor = UIColor.Clear; CustomizeColorButton(RemoveDefaultIconBtn); CustomizeColorButton(RemoveSelectedIconBtn); _modifierKeyboardActive = false; CustomizeKeyboardButtons(); ActionTbox.InputView = ModifierKeysView; ActionTbox.InputAssistantItem.LeadingBarButtonGroups = null; _actionKeys = new List <int> (); }