Beispiel #1
0
        // TimeSlider Variants

        public void SetSliderFromInt()
        {
            ApplianceState state = (ApplianceState)_objects[SINGLE_STATE];

            PUC.Types.IntegerSpace space = (PUC.Types.IntegerSpace)state.Type.ValueSpace;

            if (state.Defined)
            {
                string val = state.Value.ToString();

                if (_sentValues[val] != null &&
                    ((int)_sentValues[val]) > 0)
                {
                    int cnt = (int)_sentValues[val];
                    _sentValues[val] = --cnt;
                    return;
                }

                ((TimeSlider)_timeControl).Time    = (int)state.Value;
                ((TimeSlider)_timeControl).Maximum = space.GetMaximum().GetDoubleValue();
            }
            else
            {
                ((TimeSlider)_timeControl).Time    = 0;
                ((TimeSlider)_timeControl).Maximum = 0;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns a shallow copy of this IntegerSpace.
        /// </summary>
        /// <returns>a shallow copy of this IntegerSpace</returns>
        public override object Clone()
        {
            IntegerSpace clone = new IntegerSpace();

            clone._ranged = _ranged;
            clone._min    = _min;
            clone._max    = _max;

            clone._incremented = _incremented;
            clone._increment   = _increment;

            return(clone);
        }
Beispiel #3
0
        public override bool IsSameSpace(ValueSpace space)
        {
            if (space is IntegerSpace)
            {
                IntegerSpace ispace = (IntegerSpace)space;

                if (ispace.IsRanged() && this.IsRanged())
                {
                    if (ispace.IsIncremented() && this.IsIncremented())
                    {
                        if (!ispace.GetIncrement().IsSameValue(this.GetIncrement()))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    if (!ispace.GetMinimum().IsSameValue(this.GetMinimum()))
                    {
                        return(false);
                    }

                    if (!ispace.GetMaximum().IsSameValue(this.GetMaximum()))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Beispiel #4
0
        public void CreateExtraStates(VariableTable varTable, IBranchDataWindow window)
        {
            // Add Length State
            _listLengthState = new ApplianceState(_appliance, LIST_LENGTH_STATE, true);

            PUC.Types.IntegerSpace intSpace;
            if (_itemCount != null)
            {
                intSpace = new PUC.Types.IntegerSpace(_itemCount, _itemCount);
                if (_itemCount is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_itemCount);
                }
            }
            else if (_minimum == null && _maximum == null)
            {
                intSpace = new PUC.Types.IntegerSpace(new IntNumber(0), new IntNumber(Int32.MaxValue));
            }
            else if (_minimum != null && _maximum != null)
            {
                intSpace = new PUC.Types.IntegerSpace(_minimum, _maximum);

                if (_minimum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_minimum);
                }
                if (_maximum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_maximum);
                }
            }
            else if (_minimum != null)
            {
                intSpace = new IntegerSpace(_minimum, new IntNumber(Int32.MaxValue));

                if (_minimum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_minimum);
                }
            }
            else
            {
                intSpace = new IntegerSpace(new IntNumber(0), _maximum);

                if (_maximum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_maximum);
                }
            }

            _listLengthState.Type = new PUCType(intSpace);

            GroupNode newG = new ObjectGroupNode(_listLengthState);

            newG.Parent = this;
            this.Children.Add(newG);
            varTable.RegisterObject(_listLengthState.MakeFullName(this.FullPath), _listLengthState);
            window.AddChildWindow(_listLengthState);
            newG.Parent = null;             // remove from group so it doesn't get in the way later
            this.Children.Remove(newG);

            // Add Selection States
            _listSelectionState      = new ApplianceState(_appliance, LIST_SELECTION_STATE, _selectionReadOnly);
            _listSelectionState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState)));

            if (_selectionType == SelectionType.One)
            {
                // one selection
                newG        = new ObjectGroupNode(_listSelectionState);
                newG.Parent = this;
                this.Children.Add(newG);
                _listSelectionState.FullName = _listSelectionState.MakeFullName(this.FullPath);
                _listSelectionState.SetNetworkHandler();
                window.AddChildWindow(_listSelectionState);
                newG.Parent = null;                 // remove from group so it doesn't get in the way later
                this.Children.Remove(newG);
            }
            else
            {
                // multiple selections
                BranchGroupNode selGroup = new BranchGroupNode();

                _listSelectionLengthState      = new ApplianceState(_appliance, LIST_LENGTH_STATE, false);
                _listSelectionLengthState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState)));

                this.Children.Add(selGroup);
                selGroup.Name = LIST_SELECTION_STATE;
                newG          = new ObjectGroupNode(_listSelectionLengthState);
                newG.Parent   = selGroup;
                selGroup.Children.Add(newG);
                newG        = new ObjectGroupNode(_listSelectionState);
                newG.Parent = selGroup;
                selGroup.Children.Add(newG);

                varTable.RegisterObject(_listSelectionLengthState.MakeFullName(selGroup.FullPath), _listSelectionLengthState);
                _listSelectionState.FullName = _listSelectionState.MakeFullName(selGroup.FullPath);
                window.AddChildWindow(_listSelectionLengthState);
                window.AddChildWindow(_listSelectionState);

                this.Children.Remove(selGroup);
            }

            varTable.RegisterObject(_listSelectionState.FullName, _listSelectionState);
        }