private RandomizerCaption FromString(object value) { string[] result = ((string)value).Split(','); if (result.Length != 6) throw new ArgumentException("Could not convert to value"); try { RandomizerCaption randomizer = new RandomizerCaption(); ByteConverter byteConverter = new ByteConverter(); BooleanConverter booleanConverter = new BooleanConverter(); // Retrieve the values of the object. randomizer.Red = (byte)byteConverter.ConvertFromString(result[0]); randomizer.Green = (byte)byteConverter.ConvertFromString(result[1]); randomizer.Blue = (byte)byteConverter.ConvertFromString(result[2]); randomizer.Transparency = (byte)byteConverter.ConvertFromString(result[3]); randomizer.IsRandomizerEnabled = (bool)booleanConverter.ConvertFromString(result[4]); randomizer.IsTransparencyEnabled = (bool)booleanConverter.ConvertFromString(result[5]); return randomizer; } catch (Exception) { throw new ArgumentException("Could not convert to value"); } }
private TooltipRenderer FromString(object value) { string[] result = ((string)value).Split(','); if (result.Length != 11) throw new ArgumentException("Could not convert to value"); try { TooltipRenderer tRenderer = new TooltipRenderer(); // Retrieve the colors TypeConverter converter = new ColorConverter(); tRenderer.BorderColor = (Color)converter.ConvertFromString(result[0]); tRenderer.TitleForeColor = (Color)converter.ConvertFromString(result[1]); tRenderer.MessageForeColor = (Color)converter.ConvertFromString(result[2]); tRenderer.LightBackgroundColor = (Color)converter.ConvertFromString(result[3]); tRenderer.DarkBackgroundColor = (Color)converter.ConvertFromString(result[4]); tRenderer.BarBorderColor = (Color)converter.ConvertFromString(result[6]); tRenderer.BarBackgroundColorStart = (Color)converter.ConvertFromString(result[7]); tRenderer.BarBackgroundColorEnd = (Color)converter.ConvertFromString(result[8]); tRenderer.BarProgressColorStart = (Color)converter.ConvertFromString(result[9]); tRenderer.BarProgressColorEnd = (Color)converter.ConvertFromString(result[10]); converter = new ByteConverter(); tRenderer.Radius = (byte)converter.ConvertFromString(result[5]); return tRenderer; } catch (Exception) { throw new ArgumentException("Could not convert to value"); } }