コード例 #1
0
        public JoystickSeekBar(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            var attributes = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.JoystickSeekBar, 0, 0);

            _min = attributes.GetFloat(Resource.Styleable.JoystickSeekBar_jsb_min, (float)DefaultMin);
            _max = attributes.GetFloat(Resource.Styleable.JoystickSeekBar_jsb_max, (float)DefaultMax);

            if (_min > _max)
            {
                throw new AndroidRuntimeException("Attribute jsb_min must be less than attribute jsb_max");
            }

            Min      = (int)_min;
            Max      = (int)_max;
            Progress = (int)(((_max - _min) * 0.5) + _min);

            _eventTimer.Elapsed += (o, e) =>
            {
                DeltaProgressChanged?.Invoke(this, new DeltaChangedEventArgs()
                {
                    DeltaProgress = _deltaProgress
                });
            };

            _eventTimer.Interval = DefaultDeltaIntervalMillis;

            ProgressChanged    += JoystickSeekBar_ProgressChanged;
            StartTrackingTouch += JoystickSeekBar_StartTrackingTouch;
            StopTrackingTouch  += JoystickSeekBar_StopTrackingTouch;
        }
コード例 #2
0
        public JoystickSlider()
        {
            if (Minimum >= Maximum)
            {
                throw new Exception("Minimum must be less than Maximum!");
            }

            Value = (((Maximum - Minimum) * 0.5) + Minimum);

            _eventTimer.Elapsed += (o, e) =>
            {
                DeltaProgressChanged?.Invoke(this, new DeltaChangedEventArgs()
                {
                    DeltaProgress = _deltaProgress
                });
            };

            _eventTimer.Interval = DefaultDeltaIntervalMillis;

            ValueChanged  += JoystickValueChanged;
            DragStarted   += JoystickDragStarted;
            DragCompleted += JoystickDragCompleted;
        }