Esempio n. 1
0
        public void ColorGridTapped(UITapGestureRecognizer recognizer)
        {
            var point        = recognizer.LocationInView(_paletteView);
            var touchedLayer = _paletteView.Layer.PresentationLayer.HitTest(_paletteView.ConvertPointToView(point, _paletteView.Superview));

            if (touchedLayer != null && !string.IsNullOrWhiteSpace(touchedLayer.Name) && touchedLayer.Name.IndexOf("Color") == 0)
            {
                var actualLayer = touchedLayer.ModelLayer;

                if (_previousLayer == null)
                {
                    actualLayer.BorderWidth = 3f;
                    actualLayer.BorderColor = UIColor.White.CGColor;

                    _previousLayer = actualLayer;
                }
                else
                {
                    if (actualLayer.Name.Equals(_previousLayer.Name) == false)
                    {
                        _previousLayer.BorderWidth = 0f;
                        _previousLayer.BorderColor = UIColor.Clear.CGColor;

                        actualLayer.BorderWidth = 3f;
                        actualLayer.BorderColor = UIColor.White.CGColor;

                        _previousLayer = actualLayer;
                    }
                }
            }

            if (_previousLayer == null)
            {
                return;
            }
            var temp  = _previousLayer.Name.Split(new char[] { '_' });
            var index = int.Parse(temp[1]);

            if (index >= _colors.Count)
            {
                return;
            }
            if (ParentViewController is PopColorPickerViewController parent)
            {
                parent.SelectedColor = _colors[index];
            }
        }