Exemple #1
0
        private void CreateColorChooserTab()
        {
            CreateTab(typeof(ColorChooserView), "cc", null, Resource.Drawable.ic_palette_white_36dp, true);
            ColorChooserView ccv = (ColorChooserView)LocalActivityManager.GetActivity("cc");

            ViewModel.ColorChooser = ccv.ViewModel;
            ccv.ColorChanged      += (s, newColor) => {
                RGBPi.Core.Model.DataTypes.Color c = new RGBPi.Core.Model.DataTypes.Color(newColor);

                RGBPi.Core.Model.Message msg = new RGBPi.Core.Model.Message();
                CC fade = new CC(c);
                msg.commands = new List <RGBPi.Core.Model.Commands.Command> {
                    fade
                };
                ViewModel.SendMessage(msg);
            };
        }
Exemple #2
0
        public override bool OnTouchEvent(MotionEvent evt)
        {
            Parent.RequestDisallowInterceptTouchEvent(true);

            // Convert coordinates to our internal coordinate system
            float x = evt.GetX() - mTranslationOffset;
            float y = evt.GetY() - mTranslationOffset;

            switch (evt.Action)
            {
            case MotionEventActions.Down:
                // Check whether the user pressed on the pointer.
                float[] pointerPosition = calculatePointerPosition(mAngle);
                if (x >= (pointerPosition [0] - mColorPointerHaloRadius) &&
                    x <= (pointerPosition [0] + mColorPointerHaloRadius) &&
                    y >= (pointerPosition [1] - mColorPointerHaloRadius) &&
                    y <= (pointerPosition [1] + mColorPointerHaloRadius))
                {
                    mSlopX = x - pointerPosition [0];
                    mSlopY = y - pointerPosition [1];
                    mUserIsMovingPointer = true;
                    Invalidate();
                }
                // Check whether the user pressed on the center.
                else if (x >= -mColorCenterRadius && x <= mColorCenterRadius &&
                         y >= -mColorCenterRadius && y <= mColorCenterRadius &&
                         mShowCenterOldColor)
                {
                    mCenterHaloPaint.Alpha = (0x50);
                    CurrentColor           = (getOldCenterColor());
                    Invalidate();
                }
                // Check whether the user pressed anywhere on the wheel.
                else if (Math.Sqrt(x * x + y * y) <= mColorWheelRadius + mColorPointerHaloRadius &&
                         Math.Sqrt(x * x + y * y) >= mColorWheelRadius - mColorPointerHaloRadius &&
                         mTouchAnywhereOnColorWheelEnabled)
                {
                    mUserIsMovingPointer = true;
                    Invalidate();
                }
                // If user did not press pointer or center, report event not handled
                else
                {
                    Parent.RequestDisallowInterceptTouchEvent(false);
                    return(false);
                }
                break;

            case MotionEventActions.Move:
                if (mUserIsMovingPointer)
                {
                    mAngle = (float)Math.Atan2(y - mSlopY, x - mSlopX);
                    mPointerColor.Color = new Color(calculateColor(mAngle));

                    setNewCenterColor(mCenterNewColor = calculateColor(mAngle));

                    if (mOpacityBar != null)
                    {
                        mOpacityBar.setColor(mColor);
                    }

                    if (mValueBar != null)
                    {
                        mValueBar.setColor(mColor);
                    }

                    if (mSaturationBar != null)
                    {
                        mSaturationBar.setColor(mColor);
                    }

                    if (mSVbar != null)
                    {
                        mSVbar.setColor(mColor);
                    }

                    Invalidate();
                }
                // If user did not press pointer or center, report event not handled
                else
                {
                    Parent.RequestDisallowInterceptTouchEvent(false);
                    return(false);
                }
                break;

            case MotionEventActions.Up:
                mUserIsMovingPointer   = false;
                mCenterHaloPaint.Alpha = (0x00);

                if (ColorSelected != null && mCenterNewColor != oldSelectedListenerColor)
                {
                    ColorSelected(this, mCenterNewColor);
                    oldSelectedListenerColor = mCenterNewColor;
                }

                Invalidate();
                break;

            case MotionEventActions.Cancel:
                if (ColorSelected != null && mCenterNewColor != oldSelectedListenerColor)
                {
                    ColorSelected(this, mCenterNewColor);
                    oldSelectedListenerColor = mCenterNewColor;
                }
                break;
            }
            return(true);
        }