/* * Constructors */ public ListIndexState(Appliance appliance, ListGroupNode lg) : base(appliance, "", false) { _listGroup = lg; _dataWindow = lg.DataWindow; IntegerSpace intSpace = new IntegerSpace(new IntNumber(1), new NumberConstraint(this, lg.LengthState)); this.Type = new PUCType(intSpace); this.Labels = new LabelDictionary(); this.Labels.AddLabel(new StringValue("List Index")); this.Labels.AddLabel(new StringValue("Index")); this.ValueChangeRequested += new ValueChangeRequestedHandler(this.changeWindowIndex); _dataWindow.IndexChanged += new EventHandler(WindowIndexChanged); }
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); }
/* * Constructor */ public TimeDurationSmartCIO(GroupNode specSnippet) : base(new Panel(), specSnippet) { if (_specSnippet.IsObject()) { // single state translations /* * There are three possible translations if there is only one state. * If the state is read-only, then the time will be displayed in a label. * The state will be displayed as a TimeSlider if the state is editable, * numeric and bounded. Otherwise it will be displayed as a TimeEditor. */ ApplianceState state = (ApplianceState)_objects[SINGLE_STATE]; PUC.Types.ValueSpace space = state.Type.ValueSpace; if (space is PUC.Types.IntegerSpace) { _getString = new GetStringMethod(this.GetStringFromInt); } else if (space is PUC.Types.StringSpace) { _getString = new GetStringMethod(this.GetStringFromString); } else if (space is PUC.Types.FixedPtSpace || space is PUC.Types.FloatingPtSpace) { _getString = new GetStringMethod(this.GetStringFromFloat); } if (state.ReadOnly) { _timeControl = new Label(); if (space is PUC.Types.IntegerSpace) { _setTime = new SetControlTime(this.SetLabel); } else if (space is PUC.Types.StringSpace) { _setTime = new SetControlTime(this.SetLabel); } else { _setTime = new SetControlTime(this.SetLabel); } } else { if (space is PUC.Types.IntegerSpace) { IntegerSpace intspc = (IntegerSpace)space; if (intspc.IsRanged()) { _timeControl = new TimeSlider(); _setTime = new SetControlTime(this.SetSliderFromInt); ((TimeSlider)_timeControl).TimeChanged += new EventHandler(this.IntSliderTimeChanged); _sentValues = new Hashtable(); } else { _format = new TimeFormat[4]; _format[(int)TimeUnits.Hours] = new TimeFormat(true); _format[(int)TimeUnits.Minutes] = new TimeFormat(true); _format[(int)TimeUnits.Seconds] = new TimeFormat(true); _format[(int)TimeUnits.Fraction] = new TimeFormat(false); _timeControl = new TimeEditor(_format); _setTime = new SetControlTime(this.SetEditorFromInt); ((TimeEditor)_timeControl).TimeChanged += new EventHandler(this.IntTimeEditorChanged); } } else if (space is PUC.Types.FixedPtSpace) { FixedPtSpace fxdspc = (FixedPtSpace)space; if (fxdspc.IsRanged()) { _timeControl = new TimeSlider(); _setTime = new SetControlTime(this.SetSliderFromFixed); ((TimeSlider)_timeControl).TimeChanged += new EventHandler(this.FloatSliderTimeChanged); _sentValues = new Hashtable(); } else { _format = new TimeFormat[4]; _format[(int)TimeUnits.Hours] = new TimeFormat(true); _format[(int)TimeUnits.Minutes] = new TimeFormat(true); _format[(int)TimeUnits.Seconds] = new TimeFormat(true); _format[(int)TimeUnits.Fraction] = new TimeFormat(true); _format[(int)TimeUnits.Fraction].Maximum = ((int)Math.Pow(10, fxdspc.GetPointPosition())) - 1; _timeControl = new TimeEditor(_format); _setTime = new SetControlTime(this.SetEditorFromFloat); ((TimeEditor)_timeControl).TimeChanged += new EventHandler(this.FloatTimeEditorChanged); } } else if (space is PUC.Types.FloatingPtSpace) { FloatingPtSpace fltspc = (FloatingPtSpace)space; if (fltspc.IsRanged()) { _timeControl = new TimeSlider(); _setTime = new SetControlTime(this.SetSliderFromFloat); ((TimeSlider)_timeControl).TimeChanged += new EventHandler(this.FloatSliderTimeChanged); _sentValues = new Hashtable(); } else { _format = new TimeFormat[4]; _format[(int)TimeUnits.Hours] = new TimeFormat(true); _format[(int)TimeUnits.Minutes] = new TimeFormat(true); _format[(int)TimeUnits.Seconds] = new TimeFormat(true); _format[(int)TimeUnits.Fraction] = new TimeFormat(true); _format[(int)TimeUnits.Fraction].Maximum = 999; _timeControl = new TimeEditor(_format); _setTime = new SetControlTime(this.SetEditorFromFloat); ((TimeEditor)_timeControl).TimeChanged += new EventHandler(this.FloatTimeEditorChanged); } } else if (space is PUC.Types.StringSpace) { _format = new TimeFormat[4]; _format[(int)TimeUnits.Hours] = new TimeFormat(true); _format[(int)TimeUnits.Minutes] = new TimeFormat(true); _format[(int)TimeUnits.Seconds] = new TimeFormat(true); _format[(int)TimeUnits.Fraction] = new TimeFormat(true); _timeControl = new TimeEditor(); _setTime = new SetControlTime(this.SetEditorFromString); ((TimeEditor)_timeControl).TimeChanged += new EventHandler(this.StringTimeEditorChanged); } } if (_timeControl != null) { doNotRenderObject(state); state.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged); state.TypeChangedEvent += new PUC.ApplianceState.TypeChangedHandler(this.TypeChanged); state.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged); } } else { // multiple state translation /* * There are two possible translations if there are multiple * states. If any states are read-only, then the time will be displayed * in a label. Otherwise the time will displayed for editing in the * PocketPCControls.TimeEditor control. */ ApplianceState hourState = (ApplianceState)_objects[HOURS_LABEL]; ApplianceState minState = (ApplianceState)_objects[MINUTES_LABEL]; ApplianceState secState = (ApplianceState)_objects[SECONDS_LABEL]; ApplianceState fracState = (ApplianceState)_objects[FRACTION_LABEL]; _getString = new GetStringMethod(this.GetStringFromMultiple); if ((hourState != null && hourState.ReadOnly) || (minState != null && minState.ReadOnly) || (secState != null && secState.ReadOnly) || (fracState != null && fracState.ReadOnly)) { _timeControl = new Label(); _setTime = new SetControlTime(this.SetLabel); } else { ApplianceState[] states = new ApplianceState[4]; _format = new TimeFormat[4]; IntegerSpace space; states[(int)TimeUnits.Hours] = hourState; states[(int)TimeUnits.Minutes] = minState; states[(int)TimeUnits.Seconds] = secState; states[(int)TimeUnits.Fraction] = fracState; for (int i = (int)TimeUnits.Hours; i <= (int)TimeUnits.Fraction; i++) { if (states[i] == null) { _format[i] = new TimeFormat(false); } else { _format[i] = new TimeFormat(true); doNotRenderObject(states[i]); space = (IntegerSpace)states[i].Type.ValueSpace; if (space.IsRanged()) { _format[i].Maximum = space.GetMaximum().GetIntValue(); _format[i].Minimum = space.GetMinimum().GetIntValue(); } else { _format[i].Maximum = Int32.MaxValue; _format[i].Minimum = 0; } if (space.IsIncremented()) { _format[i].Increment = space.GetIncrement().GetIntValue(); } } } _timeControl = new TimeEditor(_format); _setTime = new SetControlTime(this.SetEditorFromMultiple); ((TimeEditor)_timeControl).TimeChanged += new EventHandler(this.MultipleTimeEditorChanged); } if (_timeControl != null) { if (hourState != null) { hourState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged); hourState.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged); } if (minState != null) { minState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged); minState.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged); } if (secState != null) { secState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged); secState.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged); } if (fracState != null) { fracState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged); fracState.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged); } } } if (_timeControl != null) { GetControl().Controls.Add(_timeControl); _timeControl.Location = new System.Drawing.Point(0, 0); _timeControl.Size = GetControl().Size; _control.Resize += new EventHandler(this.Resized); } }