Esempio n. 1
0
        /*
         * Control Change Callbacks
         */

        public void MultipleTimeEditorChanged(object source, EventArgs e)
        {
            int[] time = ((TimeEditor)_timeControl).GetTime();

            ApplianceState state = (ApplianceState)_objects[HOURS_LABEL];

            if (state != null &&
                (!state.Defined || time[(int)TimeUnits.Hours] != (int)state.Value))
            {
                state.RequestChange(time[(int)TimeUnits.Hours]);
            }

            state = (ApplianceState)_objects[MINUTES_LABEL];
            if (state != null &&
                (!state.Defined || time[(int)TimeUnits.Minutes] != (int)state.Value))
            {
                state.RequestChange(time[(int)TimeUnits.Minutes]);
            }

            state = (ApplianceState)_objects[SECONDS_LABEL];
            if (state != null &&
                (!state.Defined || time[(int)TimeUnits.Seconds] != (int)state.Value))
            {
                state.RequestChange(time[(int)TimeUnits.Seconds]);
            }

            state = (ApplianceState)_objects[FRACTION_LABEL];
            if (state != null &&
                (!state.Defined || time[(int)TimeUnits.Fraction] != (int)state.Value))
            {
                state.RequestChange(time[(int)TimeUnits.Fraction]);
            }
        }
Esempio n. 2
0
        private void _dimmerControl_ValueChanged(object sender, EventArgs e)
        {
            string val = _dimmerControl.Value.ToString();
            string stateval;

            if (_dimState.Defined)
            {
                stateval = _dimState.Value.ToString();
            }
            else
            {
                stateval = "";
            }

            // don't echo state change requests for notifications
            if (val == stateval)
            {
                return;
            }

            _dimState.RequestChange(_dimmerControl.Value);

            // keep track of the value that was sent
            if (_sentValues[val] != null)
            {
                int cnt = (int)_sentValues[val];
                _sentValues[val] = ++cnt;
            }
            else
            {
                _sentValues[val] = 1;
            }
        }
Esempio n. 3
0
        public void FloatTimeEditorChanged(object source, EventArgs e)
        {
            ApplianceState state = (ApplianceState)_objects[SINGLE_STATE];

            double correctFactor = 1000;

            if (state.Type.ValueSpace is FixedPtSpace)
            {
                correctFactor = Math.Pow(10, ((FixedPtSpace)state.Type.ValueSpace).GetPointPosition());
            }

            int[] time = ((TimeEditor)_timeControl).GetTime();

            int inttime = time[(int)TimeUnits.Hours];

            inttime = (inttime * 60) + time[(int)TimeUnits.Minutes];
            inttime = (inttime * 60) + time[(int)TimeUnits.Seconds];

            double dbltime = (double)inttime + ((double)time[(int)TimeUnits.Fraction]) / correctFactor;

            if (state != null)
            {
                state.RequestChange(inttime);
            }
        }
Esempio n. 4
0
        /*
         * Member Methods
         */

        private void _button_Activated(object sender, EventArgs e)
        {
            if (_state.Value == _value)
            {
                return;
            }
            else
            {
                _state.RequestChange(_value);
            }
        }
Esempio n. 5
0
        public void IntTimeEditorChanged(object source, EventArgs e)
        {
            int[] time = ((TimeEditor)_timeControl).GetTime();

            int inttime = time[(int)TimeUnits.Hours];

            inttime = (inttime * 60) + time[(int)TimeUnits.Minutes];
            inttime = (inttime * 60) + time[(int)TimeUnits.Seconds];

            ApplianceState state = (ApplianceState)_objects[SINGLE_STATE];

            if (state != null)
            {
                state.RequestChange(inttime);
            }
        }
Esempio n. 6
0
        public void TextChanged(object source, EventArgs a)
        {
            string stateText = null;

            if (_state.Defined)
            {
                stateText = _state.Value.ToString();
            }
            string fieldText = GetControl().Text;

            if (stateText != null && stateText == fieldText)
            {
                return;
            }

            _state.RequestChange(fieldText);
        }
Esempio n. 7
0
        public void StateClick(object sender, EventArgs a)
        {
            ApplianceState state = (ApplianceState)GetApplObj();

            if (state.Defined)
            {
                return;
            }

            if (state.Type.ValueSpace is PUC.Types.BooleanSpace)
            {
                // HACK: hopefully the variable is never undefined
                bool newValue = false;
                if (state.Defined)
                {
                    newValue = !(bool)state.Value;
                }

                state.RequestChange(newValue);
            }
        }
Esempio n. 8
0
        public void FloatSliderTimeChanged(object source, EventArgs e)
        {
            ApplianceState state = (ApplianceState)_objects[SINGLE_STATE];

            if (state != null)
            {
                double valdbl = (double)((TimeSlider)_timeControl).Time;
                string val    = valdbl.ToString();
                string stateval;

                if (state.Defined)
                {
                    stateval = state.Value.ToString();
                }
                else
                {
                    stateval = "";
                }

                // don't echo state change requests for notifications
                if (val == stateval)
                {
                    return;
                }

                state.RequestChange(valdbl);

                // keep track of the value that was sent
                if (_sentValues[val] != null)
                {
                    int cnt = (int)_sentValues[val];
                    _sentValues[val] = ++cnt;
                }
                else
                {
                    _sentValues[val] = 1;
                }
            }
        }
Esempio n. 9
0
        /*
         * Member Methods
         */

        public void Activate(object sender, EventArgs e)
        {
            _state.RequestChange(_value);
        }
Esempio n. 10
0
        public void StateClick(object sender, EventArgs a)
        {
            ApplianceState state = (ApplianceState)GetApplObj();

            state.RequestChange(((CheckBox)GetControl()).Checked);
        }
Esempio n. 11
0
        /*
         * Handler
         */

        public void itemActivated(object source, EventArgs evt)
        {
            _state.RequestChange(_value);
        }
Esempio n. 12
0
        public void StringTimeEditorChanged(object source, EventArgs e)
        {
            ApplianceState state = (ApplianceState)_objects[SINGLE_STATE];

            int[] time = ((TimeEditor)_timeControl).GetTime();

            string strtime = "";

            if (_format[(int)TimeUnits.Hours].Valid)
            {
                if (time[(int)TimeUnits.Hours] == 0)
                {
                    strtime += "00";
                }
                else if (time[(int)TimeUnits.Hours] < 10)
                {
                    strtime += "0" + time[(int)TimeUnits.Hours];
                }
                else
                {
                    strtime += time[(int)TimeUnits.Hours];
                }

                if (_format[(int)TimeUnits.Minutes].Valid)
                {
                    strtime += ":";
                }
            }

            if (_format[(int)TimeUnits.Minutes].Valid)
            {
                if (time[(int)TimeUnits.Minutes] == 0)
                {
                    strtime += "00";
                }
                else if (time[(int)TimeUnits.Minutes] < 10)
                {
                    strtime += "0" + time[(int)TimeUnits.Minutes];
                }
                else
                {
                    strtime += time[(int)TimeUnits.Minutes];
                }

                if (_format[(int)TimeUnits.Seconds].Valid)
                {
                    strtime += ":";
                }
            }

            if (_format[(int)TimeUnits.Seconds].Valid)
            {
                if (time[(int)TimeUnits.Seconds] == 0)
                {
                    strtime += "00";
                }
                else if (time[(int)TimeUnits.Seconds] < 10)
                {
                    strtime += "0" + time[(int)TimeUnits.Seconds];
                }
                else
                {
                    strtime += time[(int)TimeUnits.Seconds];
                }

                if (_format[(int)TimeUnits.Fraction].Valid)
                {
                    strtime += ".";
                }
            }

            if (_format[(int)TimeUnits.Fraction].Valid)
            {
                if (time[(int)TimeUnits.Fraction] == 0)
                {
                    strtime += "000";
                }
                else if (time[(int)TimeUnits.Fraction] < 100)
                {
                    strtime += "0" + time[(int)TimeUnits.Fraction];
                }
                else if (time[(int)TimeUnits.Fraction] < 10)
                {
                    strtime += "00" + time[(int)TimeUnits.Fraction];
                }
                else
                {
                    strtime += time[(int)TimeUnits.Fraction];
                }
            }

            if (state != null)
            {
                state.RequestChange(strtime);
            }
        }