Example #1
0
 private void SelectPickerValue(UIPickerView customModelPickerView, PickerView pickerView)
 {
     if (pickerView == null)
     {
         return;
     }
 }
        private void prepareViews()
        {
            var screenWidth = UIScreen.MainScreen.Bounds.Width;

            PreferredContentSize = new CGSize
            {
                // ScreenWidth - 32 for 16pt margins on both sides
                Width = TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular
                    ? 0
                    : screenWidth - 32,
                Height = TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular
                    ? (ViewModel.AllowCustomColors ? customColorEnabledHeightPad : customColorDisabledHeight)
                    : (ViewModel.AllowCustomColors ? customColorEnabledHeight : customColorDisabledHeight)
            };

            if (!ViewModel.AllowCustomColors)
            {
                SliderView.RemoveFromSuperview();
                PickerView.RemoveFromSuperview();
                SliderBackgroundView.RemoveFromSuperview();
                return;
            }

            // Remove track
            SliderView.SetMinTrackImage(new UIImage(), UIControlState.Normal);
            SliderView.SetMaxTrackImage(new UIImage(), UIControlState.Normal);
        }
Example #3
0
 public void UpdateTarget()
 {
     if (PickerView != null)
     {
         PickerView.ReloadAllComponents();
     }
 }
Example #4
0
        private void prepareViews()
        {
            var screenWidth = UIScreen.MainScreen.Bounds.Width;

            PreferredContentSize = new CGSize
            {
                // ScreenWidth - 32 for 16pt margins on both sides
                Width = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad
                    ? 0
                    : screenWidth > 320 ? screenWidth - 32 : 312,
                Height = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad
                    ? (ViewModel.AllowCustomColors ? customColorEnabledHeightPad : customColorDisabledHeight)
                    : (ViewModel.AllowCustomColors ? customColorEnabledHeight : customColorDisabledHeight)
            };

            if (!ViewModel.AllowCustomColors)
            {
                SliderView.RemoveFromSuperview();
                PickerView.RemoveFromSuperview();
                SliderBackgroundView.RemoveFromSuperview();
                return;
            }

            // Remove track
            SliderView.SetMinTrackImage(new UIImage(), UIControlState.Normal);
            SliderView.SetMaxTrackImage(new UIImage(), UIControlState.Normal);
        }
Example #5
0
        void ReleaseDesignerOutlets()
        {
            if (PickerView != null)
            {
                PickerView.Dispose();
                PickerView = null;
            }

            if (ResponseText != null)
            {
                ResponseText.Dispose();
                ResponseText = null;
            }

            if (SendButton != null)
            {
                SendButton.Dispose();
                SendButton = null;
            }

            if (SRDOText != null)
            {
                SRDOText.Dispose();
                SRDOText = null;
            }
        }
Example #6
0
        private void prepareViews(ColorSelectionCollectionViewSource source)
        {
            var screenWidth = UIScreen.MainScreen.Bounds.Width;

            PreferredContentSize = new CGSize
            {
                // ScreenWidth - 32 for 16pt margins on both sides
                Width  = screenWidth > 320 ? screenWidth - 32 : 312,
                Height = ViewModel.AllowCustomColors ? customColorEnabledHeight : customColorDisabledHeight
            };

            ColorCollectionView.Source = source;

            if (!ViewModel.AllowCustomColors)
            {
                SliderView.Hidden           = true;
                PickerView.Hidden           = true;
                SliderBackgroundView.Hidden = true;
                return;
            }

            // Initialize picker related layers
            var usableWidth = PreferredContentSize.Width - 28;

            PickerView.InitializeLayers(new CGRect(0, 0, usableWidth, 80));
            SliderBackgroundView.InitializeLayer(new CGRect(0, 0, usableWidth, 18));

            // Remove track
            SliderView.SetMinTrackImage(new UIImage(), UIControlState.Normal);
            SliderView.SetMaxTrackImage(new UIImage(), UIControlState.Normal);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CloseButton.SetTemplateColor(ColorAssets.Text2);

            TitleLabel.Text = Resources.ProjectColor;
            SaveButton.SetTitle(Resources.Save, UIControlState.Normal);

            prepareViews();

            //Collection View
            ColorCollectionView.RegisterNibForCell(ColorSelectionViewCell.Nib, ColorSelectionViewCell.Identifier);
            source = new ColorSelectionCollectionViewSource(ViewModel.SelectableColors);
            ColorCollectionView.Source = source;
            ViewModel.SelectableColors
            .Subscribe(replaceColors)
            .DisposedBy(DisposeBag);

            source.ColorSelected
            .Subscribe(ViewModel.SelectColor.Inputs)
            .DisposedBy(DisposeBag);

            // Commands
            SaveButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            CloseButton.Rx().Tap()
            .Subscribe(() => ViewModel.CloseWithDefaultResult())
            .DisposedBy(DisposeBag);

            // Picker view
            PickerView.Rx().Hue()
            .Subscribe(ViewModel.SetHue.Inputs)
            .DisposedBy(DisposeBag);


            PickerView.Rx().Saturation()
            .Subscribe(ViewModel.SetSaturation.Inputs)
            .DisposedBy(DisposeBag);

            SliderView.Rx().Value()
            .Select(v => 1 - v)
            .Subscribe(ViewModel.SetValue.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Hue
            .Subscribe(PickerView.Rx().HueObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Saturation
            .Subscribe(PickerView.Rx().SaturationObserver())
            .DisposedBy(DisposeBag);

            ViewModel.Value
            .Subscribe(PickerView.Rx().ValueObserver())
            .DisposedBy(DisposeBag);
        }
 partial void AddPickerView()
 {
     if (this.pickerView == null)
     {
         this.pickerView = new PickerView(this);
         this.pickerPresenter.Content = pickerView;
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (btnClose != null)
            {
                btnClose.Dispose();
                btnClose = null;
            }

            if (btnSubmit != null)
            {
                btnSubmit.Dispose();
                btnSubmit = null;
            }

            if (DialogHeaderView != null)
            {
                DialogHeaderView.Dispose();
                DialogHeaderView = null;
            }

            if (lblDialogTitle != null)
            {
                lblDialogTitle.Dispose();
                lblDialogTitle = null;
            }

            if (MainView != null)
            {
                MainView.Dispose();
                MainView = null;
            }

            if (PickerView != null)
            {
                PickerView.Dispose();
                PickerView = null;
            }

            if (ReportProviderDialogView != null)
            {
                ReportProviderDialogView.Dispose();
                ReportProviderDialogView = null;
            }

            if (ReportProviderPicker != null)
            {
                ReportProviderPicker.Dispose();
                ReportProviderPicker = null;
            }

            if (reportTextArea != null)
            {
                reportTextArea.Dispose();
                reportTextArea = null;
            }
        }
        void DoneButtonTapped(object sender, EventArgs e)
        {
            DismissViewController(true, null);
            if (OnSimplePickerViewDismissed != null)
            {
                OnSimplePickerViewDismissed(sender, e);
            }

            // Update the textfield, if available
            if (SourceField != null)
            {
                switch (pickerType)
                {
                case SimplePickerViewType.Date:
                case SimplePickerViewType.Time:
                case SimplePickerViewType.DateTime:
                    SourceField.Text = DatePicker.Date.ToString();
                    break;

                case SimplePickerViewType.List:
                    if (source != null && data != null)
                    {
                        var index = PickerView.SelectedRowInComponent(0);
                        SourceField.Text = data [index];
                    }
                    break;
                }
            }

            // Update the textfield, if available
            if (SourceLabel != null)
            {
                switch (pickerType)
                {
                case SimplePickerViewType.Date:
                case SimplePickerViewType.Time:
                case SimplePickerViewType.DateTime:
                    SourceLabel.Text = DatePicker.Date.ToString();
                    break;

                case SimplePickerViewType.List:
                    if (source != null && data != null)
                    {
                        var index = PickerView.SelectedRowInComponent(0);
                        SourceLabel.Text = data [index];
                    }
                    break;
                }
            }
        }
Example #11
0
        void SetPlaceholderColor(PickerView picker)
        {
            string  placeholderColor = picker.PlaceholderColor;
            UIColor color            = UIColor.FromRGB(GetRed(placeholderColor), GetGreen(placeholderColor), GetBlue(placeholderColor));

            var placeholderAttributes = new NSAttributedString(picker.Title, new UIStringAttributes()
            {
                ForegroundColor = color
            });

            if (Control != null)
            {
                Control.AttributedPlaceholder = placeholderAttributes;
            }
        }
Example #12
0
        void SelectOption(UITapGestureRecognizer sender)
        {
            var location  = sender.LocationInView(TableView);
            var indexPath = TableView.IndexPathForRowAtPoint(location);

            if (indexPath != null)
            {
                selectedSelectionCellIndex = indexPath.Row;
                PickerView.ReloadComponent(0);

                UIView.Animate(0.4, () => {
                    PickerHeightConstraint.Constant = 200;
                    View.LayoutIfNeeded();
                });
            }
        }
Example #13
0
 private void PrepareImagesForDisplay(GiphyMedia[] source)
 {
     if (source == null)
     {
         return;
     }
     ImageList.Clear();
     foreach (var media in source)
     {
         ImageList.Add(media);
     }
     if (ImageList.Count > 0)
     {
         PickerView.UpdateLayout();
         PickerView.ScrollIntoView(ImageList[0]);
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initialize the UI to reflect the values of the `shortcutItem`.
            var selectedShortcutItem = ShortcutItem;

            if (selectedShortcutItem == null)
            {
                throw new InvalidProgramException("The `selectedShortcutItem` was not set.");
            }

            Title = selectedShortcutItem.LocalizedTitle;

            TitleTextField.Text    = selectedShortcutItem.LocalizedTitle;
            SubtitleTextField.Text = selectedShortcutItem.LocalizedSubtitle;

            // Extract the raw value representing the icon from the userInfo dictionary, if provided.
            var userInfo = selectedShortcutItem.UserInfo;

            if (userInfo == null)
            {
                return;
            }

            var rawNumber = userInfo [AppDelegate.ApplicationShortcutUserInfoIconKey] as NSNumber;

            if (rawNumber == null)
            {
                return;
            }

            int row = rawNumber.Int32Value;

            // Select the matching row in the picker for the icon type.
            UIApplicationShortcutIconType iconType = IconTypeForSelectedRow(row);

            // The `iconType` returned may not align to the `iconRawValue` so use the `iconType`'s `rawValue`.
            PickerView.Select((int)iconType, 0, false);

            textFieldObserverToken = UITextField.Notifications.ObserveTextFieldTextDidChange((s, e) => {
                // You cannot dismiss the view controller without a valid shortcut title.
                DoneButton.Enabled = !string.IsNullOrEmpty(TitleTextField.Text);
            });
        }
Example #15
0
        void ReleaseDesignerOutlets()
        {
            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ColorCollectionView != null)
            {
                ColorCollectionView.Dispose();
                ColorCollectionView = null;
            }

            if (PickerView != null)
            {
                PickerView.Dispose();
                PickerView = null;
            }

            if (SaveButton != null)
            {
                SaveButton.Dispose();
                SaveButton = null;
            }

            if (SliderBackgroundView != null)
            {
                SliderBackgroundView.Dispose();
                SliderBackgroundView = null;
            }

            if (SliderView != null)
            {
                SliderView.Dispose();
                SliderView = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            var selectedShortcutItem = ShortcutItem;

            if (selectedShortcutItem == null)
            {
                throw new InvalidProgramException("The `selectedShortcutItem` was not set.");
            }

            if (segue.Identifier == "ShortcutDetailUpdated")
            {
                // In the updated case, create a shortcut item to represent the final state of the view controller.
                UIApplicationShortcutIconType iconType = IconTypeForSelectedRow((int)PickerView.SelectedRowInComponent(0));
                var icon = UIApplicationShortcutIcon.FromType(iconType);

                var userInfo = new NSDictionary <NSString, NSObject> (AppDelegate.ApplicationShortcutUserInfoIconKey, new NSNumber(PickerView.SelectedRowInComponent(0)));
                ShortcutItem = new UIApplicationShortcutItem(selectedShortcutItem.Type, TitleTextField.Text ?? string.Empty, SubtitleTextField.Text, icon, userInfo);
            }
        }
        private void ConfigurePickerView()
        {
            // Set the default selected rows (the desired rows to initially select will vary from app to app).
            Dictionary <ColorComponent, int> selectedRows = new Dictionary <ColorComponent, int> {
                { ColorComponent.Red, 13 },
                { ColorComponent.Green, 41 },
                { ColorComponent.Blue, 24 }
            };

            // kvp - means KeyValuePair
            foreach (var kvp in selectedRows)
            {
                var selectedRow    = kvp.Value;
                var colorComponent = kvp.Key;

                // Note that the delegate method on UIPickerViewDelegate is not triggered when manually
                // calling UIPickerView.selectRow(:inComponent:animated:). To do this, we fire off delegate
                // method manually.
                PickerView.Select(selectedRow, (int)colorComponent, animated: true);
                Selected(PickerView, selectedRow, (int)colorComponent);
            }
        }
Example #18
0
        protected override void OnElementChanged(ElementChangedEventArgs <Picker> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.BorderStyle = UITextBorderStyle.RoundedRect;

                _pickerView = e.NewElement as PickerView;

                //if(e.OldElement != null || e.NewElement != null)
                //SetPlaceholderColor(_pickerView);

                var _picker = new UIPickerView
                {
                    Model = new PickerSource(_pickerView)
                };

                SelectPickerValue(_picker, _pickerView);

                Control.InputView = _picker;
            }
        }
Example #19
0
 public static void Go(this PickerView view)
 {
     NavigationServiceHelper <PickerView> .Navigate(view);
 }
Example #20
0
            public PickerSource(PickerView pickerView)
            {
                _pickerView = pickerView;

                SelectedIndex = 0;
            }
Example #21
0
 /// <summary>
 /// Extension method for PickerView to make it easy to navigate to the appropriate
 /// view associated with the given enum.
 /// </summary>
 /// <param name="view"></param>
 public static void Go(this PickerView view, object parameter = null)
 {
     NavigationServiceHelper.Navigate(view, parameter);
 }