public int GetFieldValue( eye_tracking_mouse.Options.CalibrationMode calibration_mode) { if (field_name.StartsWith("coordinate")) { int coordinate_index = int.Parse(field_name.Split(' ')[1]); if (coordinate_index >= calibration_mode.additional_dimensions_configuration.CoordinatesCount) { return(-1); } return(calibration_mode.additional_dimensions_configuration.CoordinatesScalesInPercents[coordinate_index]); } else { var field = calibration_mode.GetType().GetField(field_name); return((int)field.GetValue(calibration_mode)); } }
public void SetFieldValue( eye_tracking_mouse.Options.CalibrationMode calibration_mode, int value) { if (field_name.StartsWith("coordinate")) { int coordinate_index = int.Parse(field_name.Split(' ')[1]); if (coordinate_index >= calibration_mode.additional_dimensions_configuration.CoordinatesCount) { return; } int[] coordinates_scales = calibration_mode.additional_dimensions_configuration.CoordinatesScalesInPercents; coordinates_scales[coordinate_index] = value; calibration_mode.additional_dimensions_configuration.CoordinatesScalesInPercents = coordinates_scales; } else { var field = calibration_mode.GetType().GetField(field_name); field.SetValue(calibration_mode, value); } }