public MssParamInfo GetParameterInfoCopy(MssParameterID parameterId) { MssParamInfo paramInfoClone = null; RunFuncOnParamInfo(parameterId, paramInfo => paramInfoClone = paramInfo.Clone()); return(paramInfoClone); }
private void paramTypeCombo_SelectedIndexChanged(object sender, EventArgs e) { MssParamType paramType = (MssParamType)this.paramTypeCombo.SelectedIndex; if (paramType != this.inputParamInfo.paramType) { this.inputParamInfo = Factory_MssParamInfo.Create(paramType, this.paramNameTextBox.Text); ConfigureFieldsFromInputParamInfo(); } }
public void Init(MssParamInfo inputParamInfo) { this.inputParamInfo = inputParamInfo.Clone(); this.paramTypeCombo.Items.Clear(); foreach (string parameterType in MssParamInfo.MssParamTypeNameList) { this.paramTypeCombo.Items.Add(parameterType); } ConfigureFieldsFromInputParamInfo(); }
public void SetVariableParamInfo(MssParamInfo varParamInfo, MssParameterID variableParamId) { lock (this.memberLock) { bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId); if (variableParamIdIsValid) { variableParamDict[variableParamId] = varParamInfo.Clone(); } else { //variableParamId does not refer to a valid variable parameter id. Debug.Assert(false); return; } } }
public void SetParamInfo(MssParameterID paramId, MssParamInfo paramInfo) { MssParamInfo prevParamInfo = GetParameterInfoCopy(paramId); if (VARIABLE_PARAM_ID_LIST.Contains(paramId)) { this.variableParamMgr.SetVariableParamInfo(paramInfo, paramId); } else if (PRESET_PARAM_ID_LIST.Contains(paramId)) { this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId, (mappingEntry) => mappingEntry.CurveShapeInfo.ParamInfoList[PRESET_PARAM_ID_LIST.IndexOf(paramId)] = paramInfo.Clone()); } else { //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST. Debug.Assert(false); return; } bool paramTypeChanged = (prevParamInfo.paramType != paramInfo.paramType); if (prevParamInfo.Name != paramInfo.Name && ParameterNameChanged != null) { ParameterNameChanged(paramId, paramInfo.Name); } //We need to check of the param type has changed here because the same raw value //can be displayed differently for different param types. if ((paramTypeChanged || prevParamInfo.RawValue != paramInfo.RawValue) && ParameterValueChanged != null) { ParameterValueChanged(paramId, paramInfo.RawValue); } if (prevParamInfo.MaxValue != paramInfo.MaxValue && ParameterMaxValueChanged != null) { ParameterMaxValueChanged(paramId, paramInfo.MaxValue); } if (prevParamInfo.MinValue != paramInfo.MinValue && ParameterMinValueChanged != null) { ParameterMinValueChanged(paramId, paramInfo.MinValue); } }
public void SetParameterRelativeValue(MssParameterID paramId, double relValue) { if (ALL_PARAMS_ID_LIST.Contains(paramId) == false) { //paramDict should always contain every possible MssParameterID Debug.Assert(false); return; } if (relValue < 0 || relValue > 1) { //relValue should be in the range [0, 1] Debug.Assert(false); return; } MssParamInfo paramInfo = GetParameterInfoCopy(paramId); double rawValue = paramInfo.MinValue + (relValue * (paramInfo.MaxValue - paramInfo.MinValue)); SetParameterRawValue(paramId, rawValue); }
protected bool RunFuncOnParamInfo(MssParameterID paramId, ParamInfoAccessor paramAccessor) { if (VARIABLE_PARAM_ID_LIST.Contains(paramId)) { return(this.variableParamMgr.RunFuncOnParamInfo(paramId, paramInfo => paramAccessor(paramInfo))); } else if (PRESET_PARAM_ID_LIST.Contains(paramId)) { return(this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId, (mappingEntry) => { int paramIndex = PRESET_PARAM_ID_LIST.IndexOf(paramId); MssParamInfo paramInfo = mappingEntry.CurveShapeInfo.ParamInfoList[paramIndex]; paramAccessor(paramInfo); })); } else { //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST. Debug.Assert(false); return(false); } }
protected bool AttemptToSetResultParamInfo() { bool resultParamInfoSetSuccessfully = true; MssParamType paramType = (MssParamType)this.paramTypeCombo.SelectedIndex; string paramName = this.paramNameTextBox.Text; this.resultParamInfo = Factory_MssParamInfo.Create(paramType, paramName); //Ensure that the min field is valid. double minValue = -1; bool minIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.minParamValueTextBox.Text, out minValue) == false) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; minIsValidNumber = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int minValueAsInt; if (int.TryParse(this.minParamValueTextBox.Text, out minValueAsInt) == false) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; minIsValidNumber = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); minValue = minValueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { minValue = this.inputParamInfo.MinValue; } else { //Unknown value input type. Debug.Assert(false); } //Ensure that the max field is valid. double maxValue = -1; bool maxIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.maxParamValueTextBox.Text, out maxValue) == false) { this.errorProvider.SetError(this.maxParamValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; maxIsValidNumber = false; } else { this.errorProvider.SetError(this.maxParamValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int maxValueAsInt; if (int.TryParse(this.maxParamValueTextBox.Text, out maxValueAsInt) == false) { this.errorProvider.SetError(this.maxParamValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; maxIsValidNumber = false; } else { this.errorProvider.SetError(this.maxParamValueTextBox, ""); maxValue = maxValueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { maxValue = this.inputParamInfo.MaxValue; } else { //Unknown value input type. Debug.Assert(false); } //Ensure that the min value is not greater then the max value. bool maxMinMakeValidRange = false; if (maxIsValidNumber && minIsValidNumber) { if (minValue >= maxValue) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_MIN_GREATER_THAN_MAX); this.errorProvider.SetError(this.maxParamValueTextBox, ERR_MIN_GREATER_THAN_MAX); resultParamInfoSetSuccessfully = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); this.errorProvider.SetError(this.maxParamValueTextBox, ""); maxMinMakeValidRange = true; } } //Check the value field. double value = -1; bool valueIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.paramValueTextBox.Text, out value) == false) { this.errorProvider.SetError(this.paramValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; valueIsValidNumber = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int valueAsInt; if (int.TryParse(this.paramValueTextBox.Text, out valueAsInt) == false) { this.errorProvider.SetError(this.paramValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; valueIsValidNumber = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); value = valueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { value = this.paramValueCombo.SelectedIndex; } else { //Unknown value input type. Debug.Assert(false); } if (valueIsValidNumber && maxMinMakeValidRange) { if (value < minValue || value > maxValue) { this.errorProvider.SetError(this.paramValueTextBox, ERR_VALUE_OUTSIDE_RANGE); resultParamInfoSetSuccessfully = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); } } //Set the resulting param info if there were no errors. if (resultParamInfoSetSuccessfully) { this.resultParamInfo.MinValue = minValue; this.resultParamInfo.MaxValue = maxValue; this.resultParamInfo.RawValue = value; } return(resultParamInfoSetSuccessfully); }
public double GetRelativeParamValue(MssParameterID paramId) { MssParamInfo paramInfo = GetParameterInfoCopy(paramId); return((paramInfo.RawValue - paramInfo.MinValue) / (paramInfo.MaxValue - paramInfo.MinValue)); }
protected bool AttemptToSetResultParamInfo() { bool resultParamInfoSetSuccessfully = true; MssParamType paramType = (MssParamType)this.paramTypeCombo.SelectedIndex; string paramName = this.paramNameTextBox.Text; this.resultParamInfo = Factory_MssParamInfo.Create(paramType, paramName); //Ensure that the min field is valid. double minValue = -1; bool minIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.minParamValueTextBox.Text, out minValue) == false) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; minIsValidNumber = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int minValueAsInt; if (int.TryParse(this.minParamValueTextBox.Text, out minValueAsInt) == false) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; minIsValidNumber = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); minValue = minValueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { minValue = this.inputParamInfo.MinValue; } else { //Unknown value input type. Debug.Assert(false); } //Ensure that the max field is valid. double maxValue = -1; bool maxIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.maxParamValueTextBox.Text, out maxValue) == false) { this.errorProvider.SetError(this.maxParamValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; maxIsValidNumber = false; } else { this.errorProvider.SetError(this.maxParamValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int maxValueAsInt; if (int.TryParse(this.maxParamValueTextBox.Text, out maxValueAsInt) == false) { this.errorProvider.SetError(this.maxParamValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; maxIsValidNumber = false; } else { this.errorProvider.SetError(this.maxParamValueTextBox, ""); maxValue = maxValueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { maxValue = this.inputParamInfo.MaxValue; } else { //Unknown value input type. Debug.Assert(false); } //Ensure that the min value is not greater then the max value. bool maxMinMakeValidRange = false; if (maxIsValidNumber && minIsValidNumber) { if (minValue >= maxValue) { this.errorProvider.SetError(this.minParamValueTextBox, ERR_MIN_GREATER_THAN_MAX); this.errorProvider.SetError(this.maxParamValueTextBox, ERR_MIN_GREATER_THAN_MAX); resultParamInfoSetSuccessfully = false; } else { this.errorProvider.SetError(this.minParamValueTextBox, ""); this.errorProvider.SetError(this.maxParamValueTextBox, ""); maxMinMakeValidRange = true; } } //Check the value field. double value = -1; bool valueIsValidNumber = true; if (this.inputParamInfo.methodOfValueInput == ValueInputType.Number) { if (double.TryParse(this.paramValueTextBox.Text, out value) == false) { this.errorProvider.SetError(this.paramValueTextBox, ERR_NOT_NUMBER); resultParamInfoSetSuccessfully = false; valueIsValidNumber = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Integer) { int valueAsInt; if (int.TryParse(this.paramValueTextBox.Text, out valueAsInt) == false) { this.errorProvider.SetError(this.paramValueTextBox, ERR_NOT_INT); resultParamInfoSetSuccessfully = false; valueIsValidNumber = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); value = valueAsInt; } } else if (this.inputParamInfo.methodOfValueInput == ValueInputType.Selection) { value = this.paramValueCombo.SelectedIndex; } else { //Unknown value input type. Debug.Assert(false); } if (valueIsValidNumber && maxMinMakeValidRange) { if (value < minValue || value > maxValue) { this.errorProvider.SetError(this.paramValueTextBox, ERR_VALUE_OUTSIDE_RANGE); resultParamInfoSetSuccessfully = false; } else { this.errorProvider.SetError(this.paramValueTextBox, ""); } } //Set the resulting param info if there were no errors. if (resultParamInfoSetSuccessfully) { this.resultParamInfo.MinValue = minValue; this.resultParamInfo.MaxValue = maxValue; this.resultParamInfo.RawValue = value; } return resultParamInfoSetSuccessfully; }
private void paramTypeCombo_SelectedIndexChanged(object sender, EventArgs e) { MssParamType paramType = (MssParamType)this.paramTypeCombo.SelectedIndex; if(paramType != this.inputParamInfo.paramType) { this.inputParamInfo = Factory_MssParamInfo.Create(paramType, this.paramNameTextBox.Text); ConfigureFieldsFromInputParamInfo(); } }