public void CreatePicker(WardrobeIDDictionary.SpriteDictionary item) { GameObject Picker = Instantiate(Resources.Load <GameObject>("Prefabs/Picker")); Picker.transform.SetParent(GameObject.Find("Canvas").transform); RectTransform rect = Picker.GetComponent <RectTransform>(); rect.anchoredPosition = Vector2.zero; //rect.offsetMin = new Vector2(0, rect.offsetMin.y); //rect.offsetMax = new Vector2(0, rect.offsetMax.y); rect.localScale = Vector2.one; Image itemImg = Picker.transform.GetChild(0).GetChild(1).GetComponent <Image>(); itemImg.sprite = Resources.Load <Sprite>(item.path); PickerButton button = Picker.GetComponentInChildren <PickerButton>(); button.item = item; TapSpace.image.raycastTarget = false; button.Picker = Picker; button.itemImg = itemImg; }
/// <summary> /// Constructor /// </summary> /// <param name="type">The Type of object that can be edited by this control.</param> protected PickerBase(Type type) { base.SetStyle(ControlStyles.Selectable, true); base.SetStyle(ControlStyles.FixedHeight, true); base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); base.ResizeRedraw = true; paintValueOnly = false; paintValueFrame = true; paintValueWidth = 20; textEditable = true; autoCompletion = true; dropDownCommit = false; editingText = false; editedType = type; typeEditor = null; typeConverter = null; typeContext = null; parseMethod = null; editedValue = null; base.SuspendLayout(); base.CausesValidation = true; pickerButton = new PickerButton(this); pickerValueBox = new PickerValueBox(this); pickerTextBox = new TextBox(); pickerListBox = new PickerListBox(this); pickerService = new PickerService(this); // pickerButton pickerButton.Visible = true; pickerButton.Cursor = Cursors.Default; pickerButton.MouseDown += new MouseEventHandler(pickerButton_MouseDown); pickerButton.MouseUp += new MouseEventHandler(pickerButton_MouseUp); // pickerValueBox pickerValueBox.Visible = false; pickerValueBox.Cursor = Cursors.Default; pickerValueBox.MouseDown += new MouseEventHandler(pickerValueBox_MouseDown); // pickerTextBox pickerTextBox.AcceptsReturn = false; pickerTextBox.AcceptsTab = false; pickerTextBox.CausesValidation = false; pickerTextBox.BorderStyle = BorderStyle.None; pickerTextBox.KeyDown += new KeyEventHandler(pickerTextBox_KeyDown); pickerTextBox.KeyPress += new KeyPressEventHandler(pickerTextBox_KeyPress); pickerTextBox.KeyUp += new KeyEventHandler(pickerTextBox_KeyUp); pickerTextBox.TextChanged += new EventHandler(pickerTextBox_TextChanged); pickerTextBox.GotFocus += new EventHandler(pickerTextBox_GotFocus); pickerTextBox.LostFocus += new EventHandler(pickerTextBox_LostFocus); pickerTextBox.Validating += new CancelEventHandler(pickerTextBox_Validating); pickerTextBox.Validated += new EventHandler(pickerTextBox_Validated); // pickerListBox pickerListBox.Visible = true; pickerListBox.MouseUp += new MouseEventHandler(pickerListBox_MouseUp); pickerListBox.SelectedIndexChanged += new EventHandler(pickerListBox_SelectedIndexChanged); // pickerBase BackColor = SystemColors.Window; ForeColor = SystemColors.WindowText; base.Controls.Add(pickerButton); base.Controls.Add(pickerValueBox); base.Controls.Add(pickerTextBox); base.ResumeLayout(); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "OpenRates"; EdgesForExtendedLayout = UIRectEdge.None; View.BackgroundColor = AppColors.Background; _currentAmount = 1; _baseCurrencyLabel = new UILabel { Text = "Currency:", Font = UIFont.BoldSystemFontOfSize(18) }; _baseButton = new PickerButton { ContentEdgeInsets = new UIEdgeInsets(15, 10, 15, 10), Layer = { BorderColor = AppColors.Blue.CGColor, BorderWidth = 1, CornerRadius = 8 } }; _baseButton.SetTitleColor(AppColors.Blue, UIControlState.Normal); _amountLabel = new UILabel { Text = "Amount:", Font = UIFont.BoldSystemFontOfSize(18) }; _amountTextFieldBorder = new UIView { BackgroundColor = UIColor.Clear, Layer = { BorderColor = AppColors.Blue.CGColor, BorderWidth = 1, CornerRadius = 8 } }; var inputAccessoryView = new UIToolbar { BarStyle = UIBarStyle.Default, TranslatesAutoresizingMaskIntoConstraints = false, Items = new[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem(UIBarButtonSystemItem.Done, AmountTextFieldDone) } }; _amountTextField = new UITextField { Text = _currentAmount.ToString("F2"), TextColor = AppColors.Blue, TextAlignment = UITextAlignment.Right, Font = UIFont.PreferredBody, KeyboardType = UIKeyboardType.DecimalPad, InputAccessoryView = inputAccessoryView }; _amountTextFieldBorder.AddSubview(_amountTextField); _ratesTable = new UITableView { AllowsSelection = false, TableFooterView = new UIView() }; _loadingView = new UIView { BackgroundColor = UIColor.Clear }; _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Large) { HidesWhenStopped = true }; _loadingView.AddSubview(_activityIndicator); View.AddSubviews(_baseCurrencyLabel, _baseButton, _amountLabel, _amountTextFieldBorder, _ratesTable, _loadingView); }