Beispiel #1
0
        public override void ControlInsidePropertyItemControlWasCreated()
        {
            base.ControlInsidePropertyItemControlWasCreated();

            var control = (IHCColorValuePowered)CreatedControlInsidePropertyItemControl;
            //!!!!
            //control.TrackBarPower.MouseWheel += TrackBarPower_MouseWheel;

            //get range
            var array = Property.GetCustomAttributes(typeof(ApplicableRangeColorValuePowerAttribute), true);

            if (array.Length != 0)
            {
                powerRange = (ApplicableRangeColorValuePowerAttribute)array[0];
            }
            if (powerRange == null)
            {
                powerRange = new ApplicableRangeColorValuePowerAttribute(0, 100, RangeAttribute.ConvenientDistributionEnum.Exponential, 2);
            }

            //configure track bar
            //if( powerRange != null )
            {
                var trackBar = control.TrackBarPower;

                trackBarDisableValueChangedEvent = true;
                powerRange.GetTrackBarMinMax(false, out int min, out int max);
                trackBar.Minimum                 = min;
                trackBar.Maximum                 = max;
                trackBar.LargeChange             = (trackBar.Maximum - trackBar.Minimum) / 10;
                trackBar.SmallChange             = (trackBar.Maximum - trackBar.Minimum) / 100;
                trackBarDisableValueChangedEvent = false;

                trackBar.GotFocus     += TrackBar_GotFocus;
                trackBar.LostFocus    += TrackBar_LostFocus;
                trackBar.MouseUp      += TrackBar_MouseUp;
                trackBar.ValueChanged += TrackBar_ValueChanged;
            }

            ////disable track bar
            ////!!!!может еще каким-то условием показывать/скрывать
            //if( powerRange == null )
            //{
            //	control.TrackBar1.Enabled = false;
            //	control.TrackBar1.Visible = false;
            //	control.TextBox1.Dock = DockStyle.Fill;
            //}
        }
Beispiel #2
0
        public void Init(ColorValuePowered value, bool noAlpha, bool powered, ApplicableRangeColorValuePowerAttribute powerRange, bool readOnly)
        {
            this.noAlpha = noAlpha;
            this.powered = powered;
            if (powered && powerRange == null)
            {
                powerRange = new ApplicableRangeColorValuePowerAttribute(0, 100, RangeAttribute.ConvenientDistributionEnum.Exponential, 2);
            }
            this.powerRange = powerRange;
            this.readOnly   = readOnly;

            noUpdate = true;

            UpdateRGBAControls(value.Color, null);

            if (powered)
            {
                numericUpDownPower.Minimum = (decimal)powerRange.Minimum;
                numericUpDownPower.Maximum = (decimal)powerRange.Maximum;

                powerRange.GetTrackBarMinMax(false, out int min, out int max);
                trackBarPower.Minimum     = min;
                trackBarPower.Maximum     = max;
                trackBarPower.LargeChange = (trackBarPower.Maximum - trackBarPower.Minimum) / 10;
                trackBarPower.SmallChange = (trackBarPower.Maximum - trackBarPower.Minimum) / 100;

                UpdatePowerControls(value.Power, null);
            }
            else
            {
                numericUpDownPower.Enabled = false;
                trackBarPower.Enabled      = false;
                label5.Enabled             = false;

                numericUpDownPower.Minimum = 0;
                numericUpDownPower.Maximum = 1;
                numericUpDownPower.Value   = 1;
                trackBarPower.Minimum      = 0;
                trackBarPower.Maximum      = 1;
                trackBarPower.Value        = 1;
            }

            //no alpha channel
            if (noAlpha)
            {
                numericUpDownAlpha.Enabled = false;
                trackBarAlpha.Enabled      = false;
                label4.Enabled             = false;
            }

            PrepareColorControls();

            if (readOnly)
            {
                colorWheel.Enabled           = false;
                colorGradientControl.Enabled = false;

                numericUpDownRed.Enabled   = false;
                numericUpDownGreen.Enabled = false;
                numericUpDownBlue.Enabled  = false;
                numericUpDownAlpha.Enabled = false;
                numericUpDownPower.Enabled = false;
                //!!!!вверх, вниз всё равно работают при ReadOnly
                //numericUpDownRed.ReadOnly = true;
                //numericUpDownGreen.ReadOnly = true;
                //numericUpDownBlue.ReadOnly = true;
                //numericUpDownAlpha.ReadOnly = true;
                //numericUpDownPower.ReadOnly = true;

                trackBarAlpha.Enabled = false;
                trackBarBlue.Enabled  = false;
                trackBarGreen.Enabled = false;
                trackBarRed.Enabled   = false;
                trackBarPower.Enabled = false;
            }

            numericUpDownRed.TextChanged   += NumericUpDown_TextChanged;
            numericUpDownGreen.TextChanged += NumericUpDown_TextChanged;
            numericUpDownBlue.TextChanged  += NumericUpDown_TextChanged;
            numericUpDownAlpha.TextChanged += NumericUpDown_TextChanged;
            numericUpDownPower.TextChanged += NumericUpDown_TextChanged;

            noUpdate = false;
        }