示例#1
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        protected void Initialize()
        {
            satBrightIndicatorSize = new CGSize(28, 28);

            var selectedColorViewHeight = (nfloat)30;
            var viewSpace = (nfloat)0;

            preview                  = new SelectedColorPreviewView();
            preview.Frame            = new CGRect(0, Bounds.Bottom - selectedColorViewHeight, Bounds.Width, selectedColorViewHeight);
            preview.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
            preview.Tag              = 1;
//            preview.Layer.ShadowOpacity = 0.6f;
//            preview.Layer.ShadowOffset = new CGSize(0, 7);
//            preview.Layer.ShadowColor = UIColor.Black.CGColor;

            satbrightPicker                   = new SaturationBrightnessPickerView();
            satbrightPicker.Frame             = new CGRect(0, selectedColorViewHeight + viewSpace, Bounds.Width, Bounds.Height - selectedColorViewHeight - selectedColorViewHeight - viewSpace - viewSpace);
            satbrightPicker.AutoresizingMask  = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            satbrightPicker.ColorPicked      += HandleColorPicked;
            satbrightPicker.AutosizesSubviews = true;
            satbrightPicker.Tag               = 2;

            huePicker                  = new HuePickerView();
            huePicker.Frame            = new CGRect(0, 0, Bounds.Width, selectedColorViewHeight);
            huePicker.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            huePicker.HueChanged      += HandleHueChanged;
            huePicker.Tag              = 3;

            var pos = huePicker.Frame.Width * huePicker.Hue;

            hueIndicator       = new HueIndicatorView();
            hueIndicator.Frame = new CGRect(pos - 10, huePicker.Bounds.Y - 2, 20, huePicker.Bounds.Height + 2);
            hueIndicator.UserInteractionEnabled = false;
            hueIndicator.AutoresizingMask       = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
            huePicker.AddSubview(hueIndicator);

            var pos2 = new CGPoint(satbrightPicker.Saturation * satbrightPicker.Frame.Size.Width,
                                   satbrightPicker.Frame.Size.Height - (satbrightPicker.Brightness * satbrightPicker.Frame.Size.Height));

            satBrightIndicator                        = new SaturationBrightnessIndicatorView();
            satBrightIndicator.Frame                  = new CGRect(pos2.X - satBrightIndicatorSize.Width / 2, pos2.Y - satBrightIndicatorSize.Height / 2, satBrightIndicatorSize.Width, satBrightIndicatorSize.Height);
            satBrightIndicator.AutoresizingMask       = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;
            satBrightIndicator.UserInteractionEnabled = false;
            satbrightPicker.AddSubview(satBrightIndicator);

            AddSubviews(huePicker, preview, satbrightPicker);
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        protected void Initialize()
        {
            satBrightIndicatorSize = new CGSize(28, 28);

            var selectedColorViewHeight = (nfloat)60;
            var viewSpace = (nfloat)1;

            preview = new SelectedColorPreviewView();
            preview.Frame = new CGRect(0, 0, Bounds.Width, selectedColorViewHeight);
            preview.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            preview.Layer.ShadowOpacity = 0.6f;
            preview.Layer.ShadowOffset = new CGSize(0, 7);
            preview.Layer.ShadowColor = UIColor.Black.CGColor;

            satbrightPicker = new SaturationBrightnessPickerView();
            satbrightPicker.Frame = new CGRect(0, selectedColorViewHeight + viewSpace, Bounds.Width, Bounds.Height - selectedColorViewHeight - selectedColorViewHeight - viewSpace - viewSpace);
            satbrightPicker.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            satbrightPicker.ColorPicked += HandleColorPicked;
            satbrightPicker.AutosizesSubviews = true;

            huePicker = new HuePickerView();
            huePicker.Frame = new CGRect(0, Bounds.Bottom - selectedColorViewHeight, Bounds.Width, selectedColorViewHeight);
            huePicker.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
            huePicker.HueChanged += HandleHueChanged;

            var pos = huePicker.Frame.Width * huePicker.Hue;
            hueIndicator = new HueIndicatorView();
            hueIndicator.Frame = new CGRect(pos - 10, huePicker.Bounds.Y - 2, 20, huePicker.Bounds.Height + 2);
            hueIndicator.UserInteractionEnabled = false;
            hueIndicator.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
            huePicker.AddSubview(hueIndicator);

            var pos2 = new CGPoint(satbrightPicker.Saturation * satbrightPicker.Frame.Size.Width,
                                   satbrightPicker.Frame.Size.Height - (satbrightPicker.Brightness * satbrightPicker.Frame.Size.Height));
            satBrightIndicator = new SaturationBrightnessIndicatorView();
            satBrightIndicator.Frame = new CGRect(pos2.X - satBrightIndicatorSize.Width / 2, pos2.Y - satBrightIndicatorSize.Height / 2, satBrightIndicatorSize.Width, satBrightIndicatorSize.Height);
            satBrightIndicator.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;
            satBrightIndicator.UserInteractionEnabled = false;
            satbrightPicker.AddSubview(satBrightIndicator);

            AddSubviews(satbrightPicker, huePicker, preview);
        }